Compile and install MySQL in Linux-Python tutorial, linuxmysql-python

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.