In Linux, Python calls MySQL
(1) first install and start mysql to determine the location of mysql/lib.
(2) install the setuptool (online or offline ).
(3) install the Mysqldb module.
MySQLdb is a Python connection module to MySQL. The following describes how to install MySQLdb in source code:
1. First download: Please go to the official website? Use_mirror = nchc
2. decompress: tar zxvf MySQL-python *
3. Enter the file directory and run the following command:
Python setup. py install
4. After the installation is complete, go to the site-packages directory under your python installation directory and check whether the following files exist. If yes, the installation is successful.
Linux: MySQL_python-1.2.3c1-py2.6-linux-i686.egg (this location is added to sys. path by default)
Mac OS X: MySQL_python-1.2.3c1-py2.6-macosx-10.4-x86_64.egg
Note: If you encounter the problem of mysql_config not found, there are two solutions:
1) ln-s/usr/local/mysql/bin/mysql_config/usr/local/bin/mysql_config
Link mysql_confi from your installation directory to the/usr/local/bin directory, so that you can access it in any directory (or put it in/usr/bin)
2) edit the site of the source code folder. cfg file, remove the comment # Before mysql_config =/usr/local/bin/mysql_config #, and modify the following path to the actual directory of mysql_config. (If you do not know where mysql_config is, run the command whereis mysql_config)
Note: If you encounter import error: libmysqlclient. so.18: cannot open shared object file: No such file or directory
Solution: locate or find libmysqlclient. so.18 (mysql installation location has been determined in the early stage)
Link path/libmysqlclient. so.18/usr/lib/libmysqlclient. so.18 (default loconfig location)
Or directly modify: vi/etc/ld. so. conf // to add libmysqlclient. so.18 to the directory.
Insert:/usr/lib/
Save and exit, and then run/sbin/ldconfig.
Python core programming version 2. (Wesley J. Chun). [Chinese version of hd pdf]
Python development technology details. (Zhou Wei, Zong Jie). [hd PDF scan version + book guide video + code]
Obtain Linux information using a Python script
Build a desktop algorithm transaction research environment using Python in Ubuntu
Python details: click here
Python: click here
This article permanently updates the link address: