30

I am trying to run a Rails two app with Ubuntu 10.04 server, sphinx, myql2 version 0.2.7 and percona server 5.5 (Myslql 5.5). mysql2 in irb works ok, I can connect to the db. this rails 2 app is working in another Centos server with MySql 5.1. When I run:

script/server -e production 

I get:

mysql2.so: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory

here are the libs I have:

# ls -l /usr/lib |grep sql
-rw-r--r--  1 root root 10581008 2011-11-18 16:51 libmysqlclient.a
lrwxrwxrwx  1 root root       16 2011-12-10 05:48 libmysqlclient_r.a -> libmysqlclient.a
lrwxrwxrwx  1 root root       20 2011-12-10 05:48 libmysqlclient.so -> libmysqlclient.so.16
lrwxrwxrwx  1 root root       29 2011-12-10 06:01 libmysqlclient.so.15 -> /usr/lib/libmysqlclient.so.16
-rw-r--r--  1 root root     7332 2011-11-18 16:44 libmysqlservices.a
-rw-r--r--  1 root root   562520 2010-02-08 06:59 libsqlite3.a
-rw-r--r--  1 root root      973 2010-02-08 06:59 libsqlite3.la
lrwxrwxrwx  1 root root       19 2011-12-07 17:15 libsqlite3.so -> libsqlite3.so.0.8.6
lrwxrwxrwx  1 root root       19 2011-03-09 18:43 libsqlite3.so.0 -> libsqlite3.so.0.8.6
-rw-r--r--  1 root root   528668 2010-02-08 06:59 libsqlite3.so.0.8.6
drwxr-xr-x  3 root root     4096 2011-12-10 05:47 mysql

How can I fix it?

Xeo
  • 129,499
  • 52
  • 291
  • 397
rtacconi
  • 14,317
  • 20
  • 66
  • 84
  • 1
    Can you located libmysqlclient_r.so? if found, symlink to this – ajreal Dec 10 '11 at 15:14
  • For CentOS, see: http://stackoverflow.com/questions/10529401/libmysqlclient-so-15-cannot-open-shared-object-file-no-such-file-or-directory – kenorb Mar 09 '14 at 12:54

7 Answers7

102

If you encounter this error again after upgrading to 12.04 (or for people arriving here after googling the title of this page after upgrading to 12.04), the following worked for me:

gem uninstall mysql2
gem install mysql2

This will recompile the gem using libmysqlclient18, and worked for me.

starball
  • 20,030
  • 7
  • 43
  • 238
Ingusmat
  • 1,131
  • 1
  • 8
  • 5
9

You need to install the development libraries. Try

sudo apt-get install libmysqlclient20-dev

or

sudo apt-get install libmysqlclient19-dev
Mario Olivio Flores
  • 2,395
  • 1
  • 20
  • 19
Bill Leeper
  • 683
  • 1
  • 10
  • 20
2

I had this error with mysql-python and solved this using pip:

pip uninstall mysql-python
pip install mysql-python
elad silver
  • 9,222
  • 4
  • 43
  • 67
2

Another option that has not been mentioned here, but has been answered in this question. Is that you have to install MySQL-python with the --no-binary option. This question is a lot easier to find, so I'm adding the answer here for reference:

First uninstall your current version of MySQL-python:

pip uninstall MySQL-python

Then install MySQL-python with the --no-binary parameter:

pip install --no-binary MySQL-python MySQL-python
Community
  • 1
  • 1
Bono
  • 4,757
  • 6
  • 48
  • 77
2

Install the mysql client libraries: apt-get install libmysqlclient16

Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254
cristian
  • 8,676
  • 3
  • 38
  • 44
0

After updated to Ubuntu 19.10. I got the error:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.20: cannot open shared object file: No such file or directory

Solution:

1) activate your virtualenv

2) (yourvirtualenv) pip uninstall mysqlclient

3) (yourvirtualenv) pip install mysqlclient

HoangYell
  • 4,100
  • 37
  • 31
0

If you are running Ubuntu/Debian, the correct solution is to install libmariadb-dev-compat and rebuild (with MariaDB 10.3+).