我試圖從我的Python程序訪問數據庫:Python的MySQL的OperationalError:1045「訪問被拒絕的用戶root @‘localhost’的
db = mysql.connect(host = 'localhost', user = 'Max', passwd = 'maxkim', db = 'TESTDB')
cursor = db.cursor()
但是,我得到的第一行的錯誤消息。代碼
OperationalError: (1045, "Access denied for user 'Max'@'localhost' (using password: YES)")
要糾正這種情況,我做了以下內容:
$ mysql -u Max-p
Enter password: maxkim
mysql> create database TESTDB;
mysql> grant usage on *.* to [email protected] identified by ‘maxkim’;
mysql> grant all privileges on TESTDB.* to [email protected] ;
mysql> exit
如果我已授予的一切ACCE ss到用戶「Max」(me)的數據庫,爲什麼我仍然不能在python中連接?
感謝,在GRANT OPTION是關鍵對我來說 – nighthawk454