diff --git a/README.md b/README.md index 7555710..a8e7856 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/Tutorial_Docs/dbmigration.MD b/Tutorial_Docs/dbmigration.MD new file mode 100644 index 0000000..967b91d --- /dev/null +++ b/Tutorial_Docs/dbmigration.MD @@ -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