0

I'm following the Lynda Ruby on Rails 3 Essential Training videos and just created a new rails application preconfigured to use a MySQL database using:

rails new app -d mysql

I then went into the /app directory and tried to start the rails server:

rails s

This is what was returned:

/usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/lib/mysql2.rb:9:in 'require': dlopen(/usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
  Reason: image not found - /usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/lib/mysql2.rb:9:in '<top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.2.4/lib/bundler/runtime.rb:68:in 'require'
    from /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.2.4/lib/bundler/runtime.rb:68:in 'block (2 levels) in require'
    from /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.2.4/lib/bundler/runtime.rb:66:in 'each'
    from /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.2.4/lib/bundler/runtime.rb:66:in 'block in require'
    from /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.2.4/lib/bundler/runtime.rb:55:in 'each'
    from /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.2.4/lib/bundler/runtime.rb:55:in 'require'
    from /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/bundler-1.2.4/lib/bundler.rb:128:in 'require'
    from /Users/joemeissler/code/lynda/config/application.rb:7:in '<top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in 'require'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in 'block in <top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in 'tap'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in '<top (required)>'
    from script/rails:6:in 'require'
    from script/rails:6:in '<main>'

Any idea what this could be? I've installed MySQL. The mysql2 gem is installed and I'm on Mountain Lion. Thanks for the help.

Substantial
  • 6,684
  • 2
  • 31
  • 40
ukejoe
  • 1
  • and the above q/a has got 100 q upvotes and 200+ on one answer and other answers have 83, 67 and 18 votes so I think you can find an answer there. – Michael Durrant Apr 09 '13 at 23:52
  • For instance `export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH` works for many. – Michael Durrant Apr 09 '13 at 23:53
  • I've run bundle install and the mysql2 gem is installed. However, when I go to /Library/Ruby/Gems/1.8/gems the mysql one isn't there. – ukejoe Apr 09 '13 at 23:58
  • did u try the export ? – Michael Durrant Apr 10 '13 at 00:23
  • I did. Now my .bash_profile has the followng: export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH – ukejoe Apr 10 '13 at 01:27
  • I just changed my rvmrc file because I remembered hearing about that before. I now try to start the server and get the following error: Exiting /usr/local/rvm/gems/ruby-1.9.3-p392/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Access denied for user 'root'@'localhost' (using password: NO) (Mysql2::Error) – ukejoe Apr 10 '13 at 01:49
  • Now I'm getting confused between installing MySQL from the website and the mysql2 gem. I'm thinking about just starting the whole thing over. – ukejoe Apr 10 '13 at 02:08
  • Not sure but I think I've seen that before and you are getting closer b ut you'll need to post a new question with the details. – Michael Durrant Apr 10 '13 at 02:30
  • I basically started the whole thing over. The Linda tutorials failed to mention a couple things such as creating a new db and editing the database.yml file, but I got it. Thanks for the input. – ukejoe Apr 10 '13 at 03:00

0 Answers0