## 事前安装 mysql, python, mysql-python
import MySQLdb
conn=MySQLdb.connect(host='127.0.0.1',user='123456',passwd='123456',db='test')
cursor = conn.cursor()
cursor.execute("""show databases""")
cursor.close();
转载于:https://my.oschina.net/jingdor/blog/88178