python - MySql Python 连接

标签 python mysql mysql-error-1045

我正在尝试将 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/

相关文章:

php - php db变量中的下划线导致问题

python - python 范围函数中的 ValueError(打印 3^(2^n))

python - 如何在 Python 中创建新的自定义记录器函数

python - 使用 mysql 创建的表,但我无法使用 python 从它中进行选择

java - 在java应用程序中生成12位唯一编号

如果字段重复,Php sql 只回显一行

mysql - 设置 root 密码并使用 Instant Rails 后无法访问 PHPmyAdmin

mysql - 如何在 VMware 中访问 Ubuntu 上的远程 mysql 主机?

python - 如何将列表转换为字符串

MySQL 复制主控 - master