MySql Python 连接
我正在尝试将 python 与 MySQL 连接,但出现此错误:
OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
我尝试解决它 6 小时但失败了。有人可以帮我吗?
I'm trying to connect python with MySQL, but I get this error:
OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: NO)")
I'm trying to solve it for 6 hours and I fail. Can any one please help me ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这意味着你忘记了密码参数,在mysql中密码参数不是必需的。
从unix命令行:
与从python登录不完全相同,
但它是相同的错误,并且很可能意味着在您的情况下密码参数根本没有进入mysql。
当我输入错误的密码时,我在命令行上收到一个非常不同的错误:
it means that you forgot the password parameter, which in mysql is not required.
from a unix command line:
not exactly the same as logging from python,
but it's the same error, and most likely means that in your case the password argument did not make it to mysql at all.
when I type the wrong password I get a very different error on the command line:
您没有指定 root 密码。
如果您从远程计算机访问 mysql...默认情况下 root 用户仅限于本地主机连接。尝试运行此命令以启用从任何地方的访问:
另请检查您的防火墙设置。
You didn't specified your root password.
If you are accessing mysql from remote computer... root user is by default limited to localhost connections only. Try running this to enable access from anywhere:
Also check your firewall settings.
因此,您需要知道您的密码是什么,并且需要使用以下命令创建数据库:
如上所述,从 mysql 命令行。
So you need to know what your password is and you need to have created a database with:
from the mysql command line as described above.
我收到此错误是因为我的配置文件中有引号。
应该是
I was getting this error because I had quotes in my config file.
should have been
执行操作时在密码列前面没有看到任何值,
如果您在 mysql 中
在 python 脚本中不要指定密码
例如
If you don't see any value in front of the password column when you do
within your mysql
In your python script don't specify the password
for example