Enable remote MySQL connection: ERROR 1045 (28000): Access denied for user(启用远程 MySQL 连接:ERROR 1045 (28000): Access denied for user)
问题描述
在 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:
- 密码包含美元符号
- 我试图从 Linux shell 进行连接
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:启用远程 MySQL 连接:ERROR 1045 (28000): Access denied for user
基础教程推荐
- SQL Server 2016更改对象所有者 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01