ubunut14.04

python2.7安装MySQLdb,3.x的版本安装PyMySQL

1source python_env/bin/activate   --**virtualenv虚拟环境

2sudo apt-get install libmysqlclient-dev libmysqld-dev

3sudo apt-get install python-dev

4、pip install MySQL-python==1.2.5

python2.7安装MySQLdb库

python2.7安装MySQLdb库

python2.7安装MySQLdb库

4、验证安装是否成功 

   1、python 进入python环境

   2、import MySQLdb

   3、quit()  退出pyhton环境

python2.7安装MySQLdb库

---------------------------------华丽分割线----------------------------------

Ubuntu16.04安装MySQL-python

下载mysql-server_5.7.17-1ubuntu16.04_amd64.deb-bundle.tar并解压

python2.7安装MySQLdb库

python2.7安装MySQLdb库

按顺序执行

sudo dpkg -i mysql-common_5.7.17-1ubuntu16.04_amd64.deb   

sudo dpkg -i libmysqlclient20_5.7.17-1ubuntu16.04_amd64.deb

sudo dpkg -i libmysqlclient-dev_5.7.17-1ubuntu16.04_amd64.deb

sudo dpkg -i libmysqld-dev_5.7.17-1ubuntu16.04_amd64.deb

sudo dpkg -i libaio1_0.3.110-1_amd64.deb 缺少这个包,下载这个包

python2.7安装MySQLdb库

sudo dpkg -i mysql-community-client_5.7.17-1ubuntu16.04_amd64.deb

sudo dpkg -i mysql-client_5.7.17-1ubuntu16.04_amd64.deb 

python2.7安装MySQLdb库