MySQL 访问被拒绝 1045 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7956031/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL access denied 1045 error
提问by Chris
I'm getting a very strange error, I've created a user 'testuser' with the following credentials:
我收到一个非常奇怪的错误,我使用以下凭据创建了一个用户“testuser”:
CREATE USER 'testuser'@'%' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%';
FLUSH PRIVILEGES;
I have also modified my /etc/mysql/my.cnf not to bind to any single address. (Which afaik should accept connections from anywhere?) And restarted mysql.
我还修改了我的 /etc/mysql/my.cnf 不绑定到任何单个地址。(哪个 afaik 应该接受来自任何地方的连接?)并重新启动 mysql。
And I can connect locally no problem.
而且我可以在本地连接没问题。
I am running inside a virtual box on ubunutu.
我在 ubunutu 上的虚拟框中运行。
Trying to connect from my windows machine, gives me MySQL error number 1045 Access denied for user 'testuser'@'192.168.0.22'.
尝试从我的 Windows 机器连接时,给了我 MySQL 错误号 1045 Access denied for user 'testuser'@'192.168.0.22'。
I'm confident that it's not a networking problem as changing the host or port gives a different error "Cannot connect to the specified instance"
我相信这不是网络问题,因为更改主机或端口会产生不同的错误“无法连接到指定的实例”
Logging in as root and looking at the users table - all looks as expected. (Single row, '%' for host and all permissions set.)
以 root 身份登录并查看用户表 - 一切都如预期。(单行,'%' 代表主机和所有权限集。)
I've been banging my head against the wall all afternoon... can anyone suggest any other possible causes for this error?
我整个下午都在用头撞墙……有人可以提出导致此错误的任何其他可能原因吗?
Thanks for any help.
谢谢你的帮助。
回答by Michael Berkowski
Run the GRANT
statement with the IDENTIFIED BY
:
使用以下GRANT
语句运行语句IDENTIFIED BY
:
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'%' IDENTIFIED BY '123456';