python 安装MySQL
2017-09-26 本文已影响0人
ZYK的轮子
1、下载 MySQL for Python
地址:http://sourceforge.net/projects/mysql-python/files/mysql-python/
我这里安装的是1.2.3版本
wget [http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz](http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz)
2、解压
tar zxvf MySQL-python-1.2.3.tar.gz
3、安装
$ cd MySQL-python-1.2.3
$ python setup.py build
$ python setup.py install
注:
如果在执行:python setup.py build 遇到以下错误:
EnvironmentError: mysql_config not found
首先查找mysql_config的位置,使用
find / -name mysql_config
,比如我的在/usr/local/mysql/bin/mysql_config
修改setup_posix.py文件,在26行:
mysql_config.path = “mysql_config”
修改为:
mysql_config.path = “/usr/local/mysql/bin/mysql_config”
保存后,然后再次执行:
python setup.py build
python setup.py install
OK,到此大功告成。
用安装Python模块出现error: command 'gcc' failed with exit status 1 ,明明装了gcc的,怎么会不行呢,然后发觉是failed不是not found,这说明这个错误个gcc没多大关系,应该是缺少某些功能模块,然后谷歌了一下,先后安装了python-devel,libffi-devel后还是不行,最后发觉要安装openssl-devel才行
可如下命令行安装:
yum install gcc libffi-devel python-devel openssl-devel