2015-11-07 31 views
0

我用XAMPP运行MySQL MySQL数据库,写一行Python代码,并得到一个错误信息:如何蟒蛇看到XAMPP

import MySQLdb 
db=MySQLdb.connect(host="localhost', port=3306, user="root", passwd="") 

_mysql_exceptions.OperationalError: (1130, "Host 'bedroom.lan' is not allowed to connect to this MySQL server") 

有没有办法为我使用Python 2.7来访问XAMPP MySQL数据库?如果没有,我是否需要在python27目录中安装MySQL服务器?

回答

0

嘘!

你试试?

import MySQLdb 
db = MySQLdb.connect("localhost","root","","bedroom") 
cursor = db.cursor() 

我在Python 2.7中测试并工作。