切换目录:
cd /usr/local/src/
一、下载资源
wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
二、解压
tar zxvf MySQL-python-1.2.3.tar.gz
三、安装
cd MySQL-python-1.2.3
vim site.cfg
配置一下mysql_config,我的在/usr/bin/下,保存并退出
python setup.py build
python setup.py install
完装完成
四、测试
MYSQL_HOST = '127.0.0.1'
MYSQL_USER = 'root'
MYSQL_PASSWD = ''
MYSQL_PORT = 3306
conn=MySQLdb.connect(host=MYSQL_HOST,user=MYSQL_USER,passwd=MYSQL_PASSWD,port=MYSQL_PORT)
cur=conn.cursor()
conn.select_db('test')
cur.close()
conn.close()