今天在服务器上安装python的mysql支持模块MySqlDb的时候遇到了一点问题.
查阅了一些资料以后发现几点..
在解压后需要修改site.cfg文件
mysql_config = /opt/mysql/bin/mysql_config
如果在编译到最后时,报告链接不上libmysqlclient_r.so的话,还需要把threadsafe设置为False。
threadsafe=False
python setup.py build
python setup.py install
这样就搞定了
#python
>>> import MySQLdb
Traceback (most recent call last):
File "", line 1, in ?
File "build/bdist.linux-i686/egg/MySQLdb/__init__.py", line 19, in ?
File "build/bdist.linux-i686/egg/_mysql.py", line 7, in ?
File "build/bdist.linux-i686/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.15: cannot open shared object file: No such file or directory
又出现如上提示错误.解决方法如下
两种方法:
1. 把~/mysql50/lib/mysql加到LD_LIBRARY_PATH环境变量中(注意把~变成绝对路径)
[code]export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mysql50/lib/mysql[/code]
2. 将建链接到/usr/lib
[code]cd /usr/lib
ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient_r.so.15
ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient_r.so
ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient.so.15
ln -s /path/to/mysql50/lib/mysql/libmysqlclient_r.so.15.0.0 libmysqlclient.so[/code]
阅读(2052) | 评论(0) | 转发(1) |