使用python的MySQLdb庫連接本地的mysql數據庫,報錯如下:
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'root'@'***-vuldb.local' (using password: YES)")
解決方法:
添加'root'@'***-vuldb.local'的訪問權限
授權root用戶擁有testDB數據庫的所有權限(某個數據庫的所有權限):
mysql>grant all privileges on testDB.* to root@***-vuldb.localhost identified by '1234';
mysql>flush privileges;//刷新系統權限表
格式:grant 權限 on 數據庫.* to 用戶名@登錄主機 identified by "密碼";
參考:http://www.cnblogs.com/fly1988happy/archive/2011/12/15/2288554.html