Installing the MYSQLDB module under Linux

Source: Internet
Author: User

1. See if the MYSQLDB module is installed

Enter the command line of Python, enter import mysqldb if there is no error, prove that the module has been installed, you can skip the following steps.

2. Download the latest MYSQLDB installation package:

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

3, enter the user mysqldb source directory, run Python setup.py build.

Error: Importerror:no module named Setuptools

FIX: Install Setuptools

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

Error: Mysql_config not found

Cause: The Mysql_config command was not found.

Solve:

1) Use the Whereis MySQL command to find the MySQL installation directory, assuming that MySQL is installed in/usr/local/mysql

2) go back to the MySQLdb source directory, vi setup_posix.py or vimsetup_posix.py open the configuration file, find the Mysql_config.path line, change the path to the MySQL installation path under the Bin directory, that is Mysql_ Config.path = "/usr/local/mysql/bin/mysql_config".

If MySQL is installed under the system default path, the Mysql_config script file is located in "/usr/bin/mysql_config". (If there is no mysql_config, you need to install the Mysql-dev package)

Error:/usr/bin/ld:cannot Find-lmysqlclient_r

Solve:

Switch to root user, perform echo "/usr/local/mysql/lib/mysql" >>/etc/ld.so.conf# please mind this/etc/ld.so.conf, this is the LD's default profile, depending on the system and different. The/usr/local/mysql/lib/mysql is related to the MySQL installation directory.

Forces the configuration file for the LD to be refreshed. Use: Ldconfig

Enter the MySQL Lib directory such as/usr/local/mysql/lib/mysql #与mysql安装目录相关.

If there is no libmysqlclient_r.so, establish a soft connection ln-s libmysqlclient.so libmysqlclient_r.so

Exit root and switch to the current user.

Error: _mysql.c:2810:error:expected declaration specifiers before ' Init_mysql '

FIX: Install Python-dev,yum installation Python-devel

4, enter the user mysqldb source directory, run sudo python setup.py install

Installing the MYSQLDB module under Linux

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.