通过Python连接远程MySQL数据库时的身份验证错误

时间:2015-05-25 11:30:12

标签: python mysql

我在连接到远程Mysql时遇到身份验证错误。 代码:

import MySQLdb as mdb

con = mdb.connect(host='xxx',port=3306,user= 'user', passwd='123',db= 'stellar')
cur = con.cursor()
cur.execute('show tables')
for r in cur:
    print(r)

错误:

Traceback (most recent call last):
  File "C:/staging_files/test.py", line 5, in <module>
    con = mdb.connect(host='xxx',port=3306,user= 'user', passwd='123',db= 'stellar')
  File "C:\Python34\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "C:\Python34\lib\site-packages\MySQLdb\connections.py", line 204, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'user'@'10.212.148.49' (using password: YES)")

我尝试了一些建议here的解决方案。 我在托管MySQL的Windows服务器上运行命令 -

GRANT ALL ON DB.stellar TO user@xxx IDENTIFIED BY '123';

我还补充说 - bind-address = 0.0.0.0到my-default.cnf文件

0 个答案:

没有答案