1. Install MySQL First
sudo Install mysql-serverapt-get isntall mysql-clientsudoinstall Libmysqlclient-dev
Check whether the installation was successful:
sudo grep MySQL
If you see a socket with MySQL in the Listen state, the installation is successful.
Log in to MySQL database:
2. Installing Mysql-python
Download mysql-python-1.2.5.zip:https://pypi.python.org/pypi/mysql-python/1.2.5 in the website
Extract
Under the mysql-python-1.2.5 directory
sudo python setup.py build
Install
If you encounter the following error:
Fatal error:python.h:no such file or directory
can be resolved by installing Python-dev
If it's python2.x,
sudo Install Python-dev
If it's python3.x,
sudo Install Python3-dev
Whether the test was successful:
Go to Python
Import MySQLdb
If it succeeds, it's installed.
"Python-mysql" installs the Python-mysql environment under Ubuntu