Compile and install MySQL in Linux-Python tutorial, linuxmysql-python
1. Download mysql-python
Address: http://sourceforge.net/projects/mysql-python/
2. Install mysql-python
Copy codeThe Code is 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/man/man1/mysql.1.gz
# Export LD_LIBRARY_PATH =/usr/include/mysql
# Python setup. py build
# Python setup. py install
Note:
1. To compile mysql-python, the mysql header file is required.
2. to install mysql-python, you need the setuptools tool.
3. Test
Copy codeThe Code is as follows:
# Python
>>> Import MySQLdb
>>>
If there is no error prompt or the following error prompt, the installation is successful.
Error message:
Copy codeThe Code is 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
Error cause:
Run python setup. py install. The 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 again.
Solution:
Run python in another directory.