我正在尝试将 python 与 MySQL 连接,但出现此错误:
OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
我花了 6 个小时尝试解决它,但我失败了。谁能帮帮我吗 ?
最佳答案
这意味着你忘记了密码参数,在mysql中是不需要的。
从 unix 命令行:
$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
$ mysql -u root -p
Enter password:
<typing password>
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 47
Server version: 5.1.37-1ubuntu5.5 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
与从 python 记录不完全相同,
但这是同样的错误,很可能意味着在您的情况下,密码参数根本没有进入 mysql。
当我输入错误的密码时,我在命令行上得到一个非常不同的错误:
$ mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
关于python - MySql Python 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5682239/