MySQL for Python Library in Python is equivalent to the jdbc driver corresponding to MySQL in Java
1. Install MySQL first
sudo apt-get install mysql-server
2. Install MySQL Python
Download mysql-python-1.2.3.tar.gz (see the attachment) and unzip it to the specified directory.
Compile and configure MySQL Python in the decompressed mysql-python-1.2.3 directory
python setup.py build
At this time, the system reports an error: environmenterror: MySQL_ config not found
Obviously there is no mysql_ Configure this file
Execute find/- name MySQL_ Config, there is no data, indicating that there is no MySQL in the system_ Configure this file
Someone on the Internet explained that MySQL installed with apt get does not have mysql_ Config is the name of this file
Solution:
(1) Ubuntu next
Execute sudo apt get install libmysqld dev
(2) Fedora next
Execute sudo Yum install Python devel
If it appears: my_ Config. H: without that file or directory, execute: sudo Yum install MySQL devel
Note: Yum is also written in Python, and/usr/bin/Python is called by default. This is the python that comes with the system itself. You can install it in/usr/local/bin/python, so you’d better not uninstall the python that comes with the system. The python you download doesn’t have the yum module.
Execute at this time find/-name mysql_ Config found this file under/usr/bin /
Then modify the site.cfg file in the mysql-python-1.2.3 directory
Remove MySQL_ Config = XXX and change to MySQL_ config=/usr/bin/mysql_ Config (in MySQL)_ The directory on the machine where the config file is located shall prevail.)
Execute the following command to compile and install successfully:
python setup.py build
python setup.py install
http://zhoujianghai.iteye.com/blog/1520666