在 Windows XP 上运行的 MySQL 5.1.31.
MySQL 5.1.31 running on Windows XP.
从 本地 MySQL 服务器 (192.168.233.142) 我可以以 root 身份连接,如下所示:
From the local MySQL server (192.168.233.142) I can connect as root as follows:
>mysql --host=192.168.233.142 --user=root --password=redacted
从远程机器(192.168.233.163),我可以看到mysql端口是开放的:
From a remote machine (192.168.233.163), I can see that the mysql port is open:
# telnet 192.168.233.142 3306
Trying 192.168.233.142...
Connected to 192.168.233.142 (192.168.233.142).
但是当我尝试从 远程 机器连接到 mysql 时,我收到:
But when trying to connect to mysql from the remote machine, I receive:
# mysql --host=192.168.233.142 --user=root --password=redacted
ERROR 1045 (28000): Access denied for user 'root'@'192.168.233.163' (using password: YES)
我在 mysql.user 中只有 2 个条目:
I have only 2 entries in mysql.user:
Host User Password
--------------------------------------
localhost root *blahblahblah
% root [same as above]
我还需要做什么才能启用远程访问?
What more do I need to do to enable remote access?
编辑
正如下面 Paulo 所建议的,我尝试将 % 的 mysql.user 条目替换为特定于 IP 的条目,因此我的用户表现在如下所示:
As suggested by Paulo below, I tried replacing the mysql.user entry for % with an IP specific entry, so my user table now looks like this:
Host User Password
------------------------------------------
localhost root *blahblahblah
192.168.233.163 root [same as above]
然后我重新启动了机器,但问题仍然存在.
I then restarted the machine, but the problem persists.
Paulo 的帮助引导我找到解决方案.它是以下内容的组合:
Paulo's help lead me to the solution. It was a combination of the following:
bash shell 将美元符号视为 扩展 到环境变量,所以我们需要用反斜杠转义它.顺便说一下,如果美元符号是密码的最后一个字符,我们不必这样做.
The bash shell treats the dollar sign as a special character for expansion to an environment variable, so we need to escape it with a backslash. Incidentally, we don't have to do this in the case where the dollar sign is the final character of the password.
举个例子,如果你的密码是pas$word",从Linux bash我们必须按如下方式连接:
As an example, if your password is "pas$word", from Linux bash we must connect as follows:
# mysql --host=192.168.233.142 --user=root --password=pas\$word
这篇关于启用远程 MySQL 连接:ERROR 1045 (28000): Access denied for user的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!