centos下安装MySQL-python
2016-08-07 23:13
441 查看
1) 下载MySQL-python
wget https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c 2) 解压缩
unzip MySQL-python-1.2.5.zip
cd MySQL-python-1.2.5
3)修改mysql配置路径, 否则提示找不到配置文件
修改 setup_posix.py 文件
vim setup_posix.py
修改 27行 mysql_config.path = "mysql_config"
mysql_config.path = “/usr/local/mysql/bin/mysql_config“
4)安装python MySQLdb
python setup.py build
sudo python setup.py install
5)测试
$ python
Python 2.7.11 (default, Aug 6 2016, 01:58:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/usr/local/python2.7/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/python2.7/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.pyc,
but /home/spider/develop/MySQL-python-1.2.5 is being added to sys.path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
提示找不到 libmysqlclient.so.18
解决办法:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
6) 重新测试,成功:
$ python
Python 2.7.11 (default, Aug 6 2016, 01:58:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
最后,作个小gg,本人个人数据API网站,提供各种数据API服务,欢迎访问 云数达 http://www.yunshuda.cn
wget https://pypi.python.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip#md5=654f75b302db6ed8dc5a898c625e030c 2) 解压缩
unzip MySQL-python-1.2.5.zip
cd MySQL-python-1.2.5
3)修改mysql配置路径, 否则提示找不到配置文件
修改 setup_posix.py 文件
vim setup_posix.py
修改 27行 mysql_config.path = "mysql_config"
mysql_config.path = “/usr/local/mysql/bin/mysql_config“
4)安装python MySQLdb
python setup.py build
sudo python setup.py install
5)测试
$ python
Python 2.7.11 (default, Aug 6 2016, 01:58:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/usr/local/python2.7/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/python2.7/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.pyc,
but /home/spider/develop/MySQL-python-1.2.5 is being added to sys.path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
提示找不到 libmysqlclient.so.18
解决办法:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
6) 重新测试,成功:
$ python
Python 2.7.11 (default, Aug 6 2016, 01:58:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
最后,作个小gg,本人个人数据API网站,提供各种数据API服务,欢迎访问 云数达 http://www.yunshuda.cn
相关文章推荐
- centos6 下安装MySQL-python
- [CentOS]安装MySQL-python,error: Setup script exited with error: command 'gcc' failed with exit status
- CentOS6.5上python-mysql环境的安装问题解决
- Centos 安装python MySQL 模块 -- MySQLdb
- centos6 下安装MySQL-python
- Centos环境下MySQL-python安装过程
- MySQLdb安装|Centos 7 下关联 python 和 MariaDB or MySQL
- centos64位 安装python mysql-client环境
- centos安装mysql-python注意事项
- 解决:centos安装python-mysql出错
- 如何在centos安装python-mysql?
- centos 安装mysql-python
- linux(centos/ubuntu) python27 mysql安装 MySQLdb
- CentOS Python 安装MySQL-python
- 关于CentOS安装无法安装mysql-python组件问题
- centos下pip安装mysql_python
- Centos6.7下安装python连接mysql环境故障解决
- Centos环境下MySQL-python安装过程
- centos 下安装MySQL-python
- MySQL-python-1.2.3c1安装(centOS6.7)