2015-11-07 29 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中測試並工作。