Rails has no access to MySQL after upgrade to 12.04

Asked by Tommy Pollák

My Ruby on Rails application with Rails 3.2.1 stopped working after upgrade to Ubunto 12.04 (from 11.10).

When starting the message is:

/home/.../.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require': libmysqlclient_r.so.16: cannot open shared object file: No such file or directory - /home/.../.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/lib/mysql2/mysql2.so (LoadError)

mysql2.so exists, so I assume libmysqlclient_r.so.16 is missing now. Why?

Question information

English Edit question
Ubuntu ruby-defaults Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
Sam (sam-j8117rz) said :

It's because mysql2-0.3.11 is looking for version 16 of libmysqlclient, and Ubuntu 12.04 is using the latest version 18 of libmysqlclient

I tried creating a symlink to point to the new 18 library, but then I get the following error:

.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require': Incorrect MySQL client library version! This gem was compiled for 5.1.61 but the client library is 5.5.22. (RuntimeError)

Which leads me to believe we may have to wait for an updated mysql2 gem

Revision history for this message
Best Sam (sam-j8117rz) said :

Actually I'm a dummy

Do a gem uninstall mysql2
Specify all versions

Then gem install mysql2

This will re-download and re-compile the gem using libmysqlclient 18

Revision history for this message
Tommy Pollák (tpollak) said :

Thanks a lot. A really good answer. So simple and so efficient!