16

I just upgraded ubuntu from 11.10 to 12.04 and after that when I run my server inside my rails project I got this error

$ rails s
/usr/share/ruby-rvm/gems/ruby-1.9.3-p125/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 - 
/usr/share/ruby-rvm/gems/ruby-1.9.3-p125/gems/mysql2-0.3.11/lib/mysql2/mysql2.so (LoadError)

any help please?

4 Answers 4

25

Go to your project and follow the steps,

rvm gemset empty <gemset name>
gem install bundler
bundle install

It will solve your problem.

If that does not work, or if you are not using rvm, please use

gem uninstall mysql2
bundle install

from one of your mysql2-using Rails project's directory.

5
  • what do you mean with <gemset name> ??
    – Azzurrio
    Apr 29, 2012 at 5:41
  • 1
    Your project's gemset name. Go to your project and hit 'rvm current' and whatever after @ letter that is your current gemset name.
    – Santosh
    Apr 29, 2012 at 5:47
  • I haven't any gemset in my rvm, when I type "$ rvm current" I got >> ruby-1.9.3-p125
    – Azzurrio
    Apr 29, 2012 at 5:56
  • 5
    Okay, then remove mysql2 gem and install it again. 'gem uninstall mysql2' then 'bundle install'
    – Santosh
    Apr 29, 2012 at 6:09
  • I was following your instructions and found out that if you empty out your gemset, then you are uninstalling bundler and you'll need to reinstall it. I added gem install bundler to your answer. Sep 21, 2012 at 22:24
1

I followed Babak's instruction that he posted and it worked after a small change.

My system is Ubuntu 12.04 server and it has Ruby1.9.3 installed so I did this

sudo apt-get install mysql-server libmysqlclient-dev

Seems like the libmysqlclient16-dev is now renamed to libmysqlclient-dev in Ubuntu 12.04

Afterwards I ran

gem install mysql2
1

Well, I would suggest double checking the ruby and the rails version and make sure they are the same ones u created your project with. Maybe you have to change the version using rvm:

  • rvm use 'Version'

Maybe you can uninstall and reinstall the mysql packages again, also try installing:

  • sudo apt-get install mysql-client mysql-server libmysqlclient16-dev

or

  • sudo apt-get install mysql-client mysql-server libmysqlclient-dev

Also try uninstalling and reinstalling your mysql gem. This blog post had a solution for this error as well, although the error was cause at a different time.

2
  • ruby & rails versions are OK, the other 2 commands are the same, and when i try to install "libmysqlclient16-dev" I got this error >> confilcts with the installed package 'libmysqlclient-dev'
    – Azzurrio
    Apr 29, 2012 at 6:11
  • In my opinion you have to reinstall a couple of these packages, even the gemfile. It might be a compatibility issue between the mysql gem you are using and the drivers you have installed for mysql. Was the link referring to the exact same problem you were having? Apr 29, 2012 at 8:23
0

For me nothing up there work. Then I found this and try to delete and create again the database.yml file. AND IT WORKS!

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.