1. Download Mysql-python
Website address: http://sourceforge.net/projects/mysql-python/
2, Installation Mysql-python
Copy the 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 requires MySQL header file.
2. Installing Mysql-python requires setuptools tools.
3. Testing
Copy the Code code as follows:
# python
>>> Import MySQLdb
>>>
If there are no error prompts or the following error prompts, the installation is successful.
Error message:
Copy the 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
Cause of Error:
Executing the python setup.py install,mysqldb module will be copied to the Python site-packages directory. If the same module exists in the directory where Python is executed, the module may be imported repeatedly.
Workaround:
You can do python in a different directory.