Steps for installing the MySQLDb module in Python

Source: Internet
Author: User

Problems and Solutions for installing the MySQLDb module in Python

My environment is: Linux version 2.4.21-4.EL (bhcompile@daffy.perf.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20) #1 Fri Oct 3 18:13:58 EDT 2003 + Python2.6.4

This article summarizes the problems I encountered during installation.

The user directory such as/home/liuguanyu/ensures that the user has the root permission.

1. check whether there is any installation.

Go to the python command line and enter import MySQLdb. If no error is reported, this module has been installed. Skip the following steps.

2. Switch to the user directory/home/liuguanyu and download the latest MySQLdb installation package: mysql-python-1.2.3c1.tar.gz. All command sets in this step are as follows:

Wget-O python-1.2.3c1.tar.gz http://cdnetworks-kr-1.dl.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz

Tar xzvf python-1.2.3c1.tar.gz

Cd MySQL-python-1.2.3c1

Python setup. py build

3. the following error occurs: ImportError: No module named setuptools.

4, back to the user directory/home/liuguanyu, install setuptools, I installed the setuptools-0.6c8, all the command sets in this step are as follows:

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

Tar xzvf setuptools-0.6c8.tar.gz

Cd setuptools-0.6c8

Python setup. py build

Sudo python setup. py install

5. Return to the MySQLdb source code directory.

6. Run python setup. py build

7. Error: mysql_config not found
8. The error returned in the previous step is because the mysql_config command is not found.

9. Run the whereis mysql command to find the mysql installation directory. Assume that mysql is installed in/usr/local/mysql.

10. Return to the MySQLdb source code directory.

11. Run vi setup_posix.py or vim setup_posix.py to open the configuration file. In this case, locate mysql_config.path and add the mysql installation path and bin directory in step 1 to the path. Mysql_config.path = "/usr/local/mysql/bin/mysql_config"

12. Run python setup. py build again.

13. Error/usr/bin/ld: cannot find-lmysqlclient_r

14. Switch to the root user and run

Echo "/usr/local/mysql/lib/mysql">/etc/ld. so. conf # Please advise this/etc/ld. so. conf. This is the default configuration file of the ld, which varies depending on the system. /Usr/local/mysql/lib/mysql is related to the mysql installation directory.

15. Force refresh the ld configuration file. Use: ldconfig

16. Enter the mysql lib directory, for example,/usr/local/mysql/lib/mysql #, which is related to the mysql installation directory.

17. If libmysqlclient_r.so is absent, a soft connection ln-s libmysqlclient. so libmysqlclient_r.so will be established.

18. Exit root and switch to the current user, such as liuguanyu.

19. Go to the MySQLdb source code directory.

20. Run python setup. py build again.

21. Run sudo python setup. py install

22. Repeat the first step.

Original article: http://blog.csdn.net/ndcs_dhf2008/article/details/5709401

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.