1

I am completely new to Ruby, Rails, and MySQL. I am trying to start a new project and start the default server and I get the error listed below. I have the following installed:

  • Ruby : ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.8.0]
  • Rails: rails (3.0.7)
  • MySql: mysql2 (0.2.7)
  • RubyGems: 1.7.2

Error is below:

$ rails s
/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlsym(0x251680, Init_mysql2): symbol not found - /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle (LoadError)
    from /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
    from /Users/nelsonwittwer/Sites/simple_cms/config/application.rb:7
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
    from script/rails:6:in `require'
    from script/rails:6

I'm not quite sure where to go from here and would love any help you may have. Thank you.

Rein Henrichs
  • 15,437
  • 1
  • 45
  • 55
James
  • 11
  • 3

2 Answers2

0

make sure you have mysql2 gem installed in your ruby system. To check it use gem list -d. If mysql2 gem not found, in ubuntu you must install following library before install mysql2 gem :

# sudo apt-get install libmysqlclient15-dev  (for mysql-5.*)

# sudo apt-get install  libmysql-ruby  ruby-dev

After that, you could install with sudo gem install mysql2 and make sure your adapter value inside database.yml is mysql2. Another issue is Library not loaded, you can view this link if that the problem Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem

Community
  • 1
  • 1
Agung Prasetyo
  • 4,353
  • 5
  • 29
  • 37
0

You need the mySQL gem installed on your system.

Now, DO NOT use apt-get to install this, as apt-get often has old versions of the ruby libraries.

Also, I would highly recommend you use SQLite when starting out. And, Bundler is also very helpful (described in the railstutorial)

On ubuntu/debian based distributions (and you really want to use MySQL):

If you are using ruby 1.8.x (check with ruby -v):

sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby-dev
sudo gem install mysql2 

If you are using ruby 1.9.x:

sudo apt-get install libmysqlclient-dev
sudo apt-get install ruby1.9.1-dev
sudo gem install mysql2
Dhaivat Pandya
  • 6,499
  • 4
  • 29
  • 43