Skip to content

Commit

Permalink
Adds information to help with db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kinseyost committed Sep 26, 2016
1 parent a721b3c commit ec80f49
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ Or in cloud9
rails s -b $IP -p $PORT -e c9
```

## Migrating Database
To get the same database as is in a certain project, follow the instructions [here](./Tutorial_Docs/dbmigration.MD).

## Navigating this tutorial
[Most of the commits](https://github.com/kinseyost/ruby-tutorial/commits/master) represent a lesson, to follow along go through each of the commits to see what the lesson entails. Most of them are explained pretty well through the commit message.

Expand Down
54 changes: 54 additions & 0 deletions Tutorial_Docs/dbmigration.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Migrating Database
After you've gotten [mysql installed](https://github.com/kinseyost/ruby-tutorial#install-mysql), there might be a few gotchas depending on your setup.

Check the config/database.yml to get the appropriate `username`. You will also need to find the `password`,
which will be placed in the `IDENTIFIED BY ''` bit of sql below.

### Open mysql with root user
```
mysql -u root
```
Once in mysql, create a user of the appropriate name.

### Create appropriate user
```
CREATE_USER 'simple_cms'@'localhost';
```

### Grant all priveleges to said user.
```
GRANT ALL PRIVILEGES ON *.*
TO 'simple_cms'@'localhost';
IDENTIFIED BY '';
```

### Create the database
```
CREATE DATABASE simple_cms_development;
```

### Exit mysql
```
exit
```

## Migrate the db
```
rake db:migrate
```

### Problems
If you are seeing a problem such as
```
$ rake db:create --trace
rake aborted!
dlopen(/Users/username/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/username/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/username/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
```

Try this
```
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
```
And checkout [this](http://stackoverflow.com/questions/10557507/rails-mysql-on-osx-library-not-loaded-libmysqlclient-18-dylib) out for more information

0 comments on commit ec80f49

Please sign in to comment.