1, download Mysql-python
Website address: http://sourceforge.net/projects/mysql-python/
2. Installation Mysql-python
Copy Code code as follows:
# TAR-ZXVF Mysql-python-1.2.3.tar.gz
# CD mysql-python-1.2.3
# Whereis Mysql_config
Mysql_config:/usr/bin/mysql_config/usr/share/man/man1/mysql_config.1.gz
# VI Site.cfg
Threadsafe = False
Mysql_config =/usr/bin/mysql_config
# Whereis MySQL
MySQL:/usr/bin/mysql/usr/lib/mysql/usr/include/mysql/usr/share/mysql/usr/share/man/man1/mysql.1.gz
# Export Ld_library_path=/usr/include/mysql
# python setup.py Build
# python setup.py Install
Attention:
1. Compile Mysql-python need MySQL header file.
2. Installation of Mysql-python requires Setuptools tools.
3, testing
Copy Code code as follows:
# python
>>> Import MySQLdb
>>>
If there are no error prompts or the following error prompts, the installation is successful.
Error Tip:
Copy Code code as follows:
/usr/local/lib/python2.6/site-packages/mysql_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from/usr/local/lib/python2.6/site-packages/mysql_python-1.2.3-py2.6-linux-x86_ 64.EGG/_MYSQL.PYC, but/root/mysql-python-1.2.3 is being added to Sys.path
The reason for the error:
Executing the python setup.py install,mysqldb module will be copied to the Python site-packages directory. If you have the same module in the directory where Python is executing, you may be able to repeat the import module.
Solution:
You can do python in a different directory.