MySQL mysql2.so:libmysqlclient_r.so.15:无法打开共享对象文件:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8456300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql2.so: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory
提问by rtacconi
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:
我正在尝试使用 Ubuntu 10.04 服务器、sphinx、myql2 版本 0.2.7 和 percona 服务器 5.5 (Myslql 5.5) 运行 Rails 两个应用程序。irb 中的 mysql2 工作正常,我可以连接到数据库。这个 rails 2 应用程序正在另一个带有 MySql 5.1 的 Centos 服务器中工作。当我运行时:
script/server -e production
I get:
我得到:
mysql2.so: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory
mysql2.so:libmysqlclient_r.so.15:无法打开共享对象文件:没有这样的文件或目录
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?
我该如何解决?
回答by Ingusmat
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:
如果您在升级到 12.04 后再次遇到此错误(或者对于升级到 12.04 后在谷歌搜索此页面的标题后到达这里的人),以下对我有用:
gem uninstall mysql2
gem install mysql2
This will recompile the gem using libmysqlclient18, and worked for me.
这将使用 libmysqlclient18 重新编译 gem,并为我工作。
Hope that helps someone out there.
希望能帮助那里的人。
回答by Bill Leeper
You need to install the development libraries. Try
您需要安装开发库。尝试
sudo apt-get install libmysqlclient20-dev
or
或者
sudo apt-get install libmysqlclient19-dev
回答by cristian
Install the mysql client libraries: apt-get install libmysqlclient16
安装 mysql 客户端库: apt-get install libmysqlclient16
回答by elad silver
I had this error with mysql-python and solved this using pip:
我在使用 mysql-python 时遇到了这个错误,并使用 pip 解决了这个问题:
pip uninstall mysql-python
pip install mysql-python
回答by Bono
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:
此处未提及但已在此问题中回答的另一个选项。是你必须安装MySQL-python
的--no-binary
选项。这个问题更容易找到,所以我在这里添加答案以供参考:
First uninstall your current version of MySQL-python
:
首先卸载您当前版本的MySQL-python
:
pip uninstall MySQL-python
Then install MySQL-python
with the --no-binary
parameter:
然后MySQL-python
使用--no-binary
参数安装:
pip install --no-binary MySQL-python MySQL-python
回答by HoangYell
After updated to Ubuntu 19.10. I got the error:
更新到 Ubuntu 19.10 后。我得到了错误:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.20: cannot open shared object file: No such file or directory
django.core.exceptions.ImproperlyConfigured:加载 MySQLdb 模块时出错:libmysqlclient.so.20:无法打开共享对象文件:没有这样的文件或目录
Solution:
解决方案:
1) activate your virtualenv
1)激活你的virtualenv
2) (yourvirtualenv) pip uninstall mysqlclient
2)(你的虚拟环境) pip uninstall mysqlclient
3) (yourvirtualenv) pip install mysqlclient
3)(你的虚拟环境) pip install mysqlclient