1
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
  Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
    from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2.rb:8
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
    from /Users/imran/simple_cms/config/application.rb:7
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
    from script/rails:6:in `require'
    from script/rails:6

Does anyone know how i can fix this?? Thanks in advance ;-)

now i'm getting this?

dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace

dyld: Symbol not found: _mysql_get_client_info Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace

Trace/BPT trap

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Imran
  • 11,350
  • 20
  • 68
  • 78
  • do you have `mysql2` gem installed? – fl00r Apr 29 '11 at 15:16
  • Are you sure you installed MySQL (both the Gem and MySQL itself)? – slhck Apr 29 '11 at 15:17
  • mysql is running and i got mysql (2.8.1) mysql2 (0.3.2) gems installed? – Imran Apr 29 '11 at 15:19
  • yep! macbook pro snow leopard – Imran Apr 29 '11 at 15:25
  • Yes, he's on a Mac. Everything is installed in /Library. – michaeltomer Apr 29 '11 at 15:26
  • Why do you use mysql (2.8.1) ? I think you can't use both for one application, do you have this 2 gems in your GemFile ? – Dinatih Apr 29 '11 at 15:32
  • I'm using a MAC with rvm, MAMP (mysql5), rails 3 and gem mysql2 (after switch from mysql), and ruby 1.9.2 – Dinatih Apr 29 '11 at 15:46
  • @Dinatih why did you switch from mysql to MAMP (mysql5)? Did you have problems with mysql? – Imran Apr 29 '11 at 17:50
  • I switched because I also switch from ruby 1.8.7 to 1.9.2 (1.9.2 and the gem mysql are some trouble with caractere encoding). I use MAMP because I just prefere it, and as it's a little difficult to use both MAMP and rails (you must get mysql's header files separately and put it in MAMP folder), I thought you had the same problem – Dinatih Apr 29 '11 at 18:59
  • Do you use the system' MySQL version of MAC OS X or do you have reinstalled it (for example with macport or manually) ? – Dinatih Apr 29 '11 at 19:08

5 Answers5

1

Updated MySQL again from installer (say, mysql-5.5.10-osx10.6-x86_64).

Then MySQL2 gem: $ sudo gem install mysql2 -- --with-mysql-config=/usr/local/mysql-5.5.10-osx10.6-x86_64/bin/mysql_config

It worked for me.

Marko
  • 20,385
  • 13
  • 48
  • 64
Shan Valleru
  • 3,093
  • 1
  • 22
  • 21
1

may be this post is similiar with your 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
  • Thanks! this page explained whats happening but i still could'nt fix the problem http://lightyearsoftware.com/2011/02/mysql-5-5-on-mac-os-x/ – Imran Apr 29 '11 at 18:54
1

Try this:

export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"

Put this in your .profile (or .bashrc) and type this command

my_term> source .profile

replace '/usr/local/mysql/lib/' by where you MySQL client is installed

Dinatih
  • 2,456
  • 1
  • 21
  • 21
0

I also had this problem and any suggestions I found here or in other questions didn't get me anywhere, but running as root did (with sudo rails s). I guess that when running as root, it uses the right path to the mysql library, but changing it with install_name_tool as described in one of the links here doesn't work, too. As long as I don't find the issue, I need to start my rails app with sudo.

DenisStad
  • 27
  • 1
  • 4
0

For permanent fix, try to create a soft link by command -

sudo ln -s /usr/local/mysql/lib/libmysqlclient.16.dylib /usr/lib/libmysqlclient.16.dylib

http://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html

Ritesh Kumar
  • 2,183
  • 2
  • 20
  • 32