gpt4 book ai didi

MySQL:用户 'user' @'IP_ADDRESS' 的访问被拒绝 - 允许某些主机的远程访问对其他主机失败

转载 作者:行者123 更新时间:2023-11-29 10:49:23 25 4
gpt4 key购买 nike

背景:我可以从某些子网访问 mysql 实例,但不能从其他子网访问。至少看起来是这样。网络 10.0.21.xx 上的计算机能够连接到 MySQL 实例。但从 10.0.7.xx 开始,我收到“使用密码的用户访问被拒绝”。有趣的是,MySQL 安装在与其不验证用户身份的计算机相同的子网 (10.0.7.xx) 上。

这是我发出的命令。

 mysql -u user -h 10.0.7.21 -p

我得到的错误是

ERROR 1045 (28000): Access denied for user 'user'@'10.0.7.30' (using password: YES)

我已经检查了 /etc/mysql/my.cnf 文件并确保 mysqld 监听所有 IP 地址。我还检查了授予权限,以确保它不与特定的 IP 地址绑定(bind)。

如果有人能给我更多的见解,我将不胜感激。如果您需要我添加额外信息,请告诉我。

感谢您的阅读。

最佳答案

事实证明这是一个 DNS 问题。促使我走这条路的是 MySQL Documenation :

If you specify a host name when trying to connect, but get an error message where the host name is not shown or is an IP address, it means that the MySQL server got an error when trying to resolve the IP address of the client host to a name:

它提供的解决方案之一是刷新 DNS 主机缓存;就我而言,我没有这张 table 。

以下是文档中建议的修复:

Some permanent solutions are:

  • Determine what is wrong with your DNS server and fix it.

  • Specify IP addresses rather than host names in the MySQL grant tables.

  • Put an entry for the client machine name in /etc/hosts on Unix or \windows\hosts on Windows.

  • Start mysqld with the --skip-name-resolve option.

  • Start mysqld with the --skip-host-cache option.

就我而言,我将本地 DNS 服务器的 IP 地址添加到客户端的/etc/resolv.cnf 文件中,然后重新启动网络服务(服务网络重新启动)。

关于MySQL:用户 'user' @'IP_ADDRESS' 的访问被拒绝 - 允许某些主机的远程访问对其他主机失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44010575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com