我尝试使用以下方法从 Python 3.3 访问 MySQL:
import mysql.connector
config = {
'user': '###',
'password': '******',
'host': '##.##.#.##',
'database': '########',
'port': '####',
'raise_on_warnings': True,
}
cnx = mysql.connector.connect(**config)
cnx.close()
但是当我运行上面的代码时,我得到了这个错误:
mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user '###'@'##.##.#.###' (using password: YES);
为什么会出现此错误,我该如何解决?
最佳答案
我想为原因添加另一种可能性:您的 MySQL 和 mysql-connector-python
之间的版本不匹配。我在使用 MySQL 5.6.24-72.2-log
和 mysql-connector-python==8.0.13
时遇到了这个问题。降级到 mysql-connector-python==8.0.5
解决了这个问题。虽然我使用的是 Python 2,但希望这会为调试提供更多线索。
关于python - 从 Python 3 : Access denied for user 访问 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32852163/