[Edit 2015-12-15 - Reader "Zane" was kind enough to let me know the link was busted. Looks like a new edition was released and can be seen here. Another tutorial can be viewed here.]
To start a project using mysql (instead of mysqlite), do this:
rails new app_name -d mysql
I am running OSX with a mysql image downloaded from Oracle. When I tried to run this command:
rails generate scaffold User name:string email:string
The command failed with:
Library not loaded: libmysqlclient.18.dylib (LoadError)
Here is the fix:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
The tutorial next has us run:
bundle exec rake db:migrate
Which results in this error:
rake aborted!
Access denied for user 'root'@'localhost' (using password: NO)
The fix is to edit your config/database.yml file:
Scroll down and replace update username: and password: values appropriately.
Re-running the command above yields:
rake aborted!
Unknown database 'app_name_development'
The fix is to create a new database:
rake db:create
Now the bundle exec command attempted above will work.
We can confirm this worked by interacting with the demo app and running the following commands:
mysql -u root -p
show databases;
use demo_app_development;
show tables;
select * from users;
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.