安装python与mysql连接的模块

python标准库中没有和mysql连接的库,如果自己不单独写与mysql连接的库,就需要另外去安装MySQLdb这个模块:

到官网https://www.python.org/downloads/去下载需要的版本,这里下载  MySQL-python-1.2.3.tar.gz

tar xf  MySQL-python-1.2.3.tar.gz  

cd MySQL-python-1.2.3

yum  install -y mysql-devel  python-devel

yum groupinstall "Development Tools"

错误解决:

1.error:EnvironmentError: /usr/local/mysql/bin/mysql_config not found

解决办法:yum install -y mysql-devel以后,  

[root@localhost MySQL-python-1.2.3]# find / -name mysql_config
/etc/alternatives/mysql_config
/var/lib/alternatives/mysql_config
/usr/bin/mysql_config
/usr/lib64/mysql/mysql_config


挑选其中任意一个文件做链接: ln -s   /etc/alternatives/mysql_config /usr/local/mysql/bin/mysql_config

2.error: pymemcompat.h:10:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
                    ^
compilation terminated.

解决办法:安装  yum install -y python-devel



接着安装


/usr/local/src/python/MySQL-python-1.2.3

python setup.py build

python  setup.py install


到这基本就成功了


Author:网名为什么那么长

路过:

安装pip:  http://blog.csdn.net/olanlanxiari/article/details/48086917

http://blog.itpub.net/26855487/viewspace-1063395/

wget   http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c8.tar.gz

http://blog.csdn.net/tianxionj/article/details/51789234


你可能感兴趣的:(安装python与mysql连接的模块)