简体   繁体   中英

Setting up MYSQL with the latest version of Ruby on Rails

I am a total ruby on rails noob, and I have been trying to follow Lynda.com's ruby on rails 3 essential training. However, this was made when mysql was the default database, and somehow since then the default has been changed to sqlite3.

I have absolutely no idea how to handle anything related to ruby, migrations, or databases, and following along with the tutorial requires me being able to change over from the default of sqlite to mysql. Is there anyone that can help me do this? I think I have so far managed to completely screw everything up, so here's what I did for the record:

1. Installed mysql. Its running and working on my mac. This is whats displayed when I go into the mysql interface:

Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 8 Server version: 5.5.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.

2. Changed databases.yml over to the mysql structure, for example:

development: adapter: mysql2 encoding: utf8 database: simple_cms_development username: simple_cms password: password socket: /tmp/mysql.sock

3. Went into the gemfile and added gem 'mysql2' , although I kept the sqlite3 one in there as well. 4. Ran 'bundle install' to make sure that the mysql2 gem was installed. It kept putting everything from the bundle into a folder called mysql2 due to an earlier mistake, so I changed the path to 'gems' 5. Ran 'gem list' and mysql2 was in the list

Then I ran db:migrate and got this error, which I looked up and tried every single solution I found on this site, and not a single one worked.

rake aborted! dlopen(/Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib Referenced from: /Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle Reason: image not found - /Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle /Users/Jeff/Sites/simple_cms/Rakefile:4

I am completely and totally stumped, and sadly will not be able to learn any more rails if I can't get past this. Can anyone help? Thank you so much : )

This is an old one :)

Just do:

sudo install_name_tool -change libmysqlclient.16.dylib \
  /usr/local/mysql/lib/libmysqlclient.16.dylib \
  /Users/Jeff/Sites/simple_cms/gems/ruby/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

Source: http://freddyandersen.wordpress.com/2010/10/03/mysql-5-5-snow-leopard-and-rails/

install_name_tool documentation: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM