MySQL:用户'user'@'IP_ADDRESS'的访问被拒绝-某些主机允许的远程访问对其他主机失败 [英] MySQL: Access denied for user 'user'@'IP_ADDRESS' - Remote access allowed for some hosts fails for other hosts

查看:343
本文介绍了MySQL:用户'user'@'IP_ADDRESS'的访问被拒绝-某些主机允许的远程访问对其他主机失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Background: I am able to access a mysql instance from some subnets but not others. At least that is what it appears to be. Machines on network 10.0.21.xx are able to connect to the MySQL instance. But from 10.0.7.xx, I get "Access denied for user using password". Interestingly, MySQL is installed on the same subnet (10.0.7.xx) as the machines that it will not authenticate users from.

这是我发出的命令.

 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地址.

I have already checked the /etc/mysql/my.cnf file and made sure that mysqld listens from all IP addresses. I have also checked grant privileges to make sure it is not tied to specific ip addresses.

如果有人可以给我更多的见解,我将不胜感激.如果您需要我添加其他信息,请告诉我.

I'd appreciate if someone can give me additional insight. If you need me to add extra information kindly let me know.

感谢阅读.

推荐答案

事实证明这是DNS问题.导致我走这条路的是 MySQL文档:

It turns out it was a DNS issue. What led me to go this route is the MySQL Documenation:

如果您在尝试连接时指定了主机名,但收到一条错误消息,其中未显示主机名 是IP地址,则表示尝试将客户端主机的IP地址解析为名称时,MySQL服务器出错:

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主机缓存.就我而言,我没有这张桌子.

One of the solutions it offers is to flush the DNS host cache; in my case I didn't have this table.

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

Here are recommended fixes from the documentation:

一些永久性解决方案是:

Some permanent solutions are:

  • 确定您的DNS服务器出了什么问题并进行修复.

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

在MySQL授权表中指定IP地址而不是主机名.

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

在Unix上的/etc/hosts中输入客户端计算机名称的条目,或者 \ windows \ Windows上的主机.

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

使用--skip-name-resolve选项启动mysqld.

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

使用--skip-host-cache选项启动mysqld.

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

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

In my case I added the IP address of our local DNS server to the client's /etc/resolv.cnf file and then restarted network services (service networking restart).

这篇关于MySQL:用户'user'@'IP_ADDRESS'的访问被拒绝-某些主机允许的远程访问对其他主机失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆