用户' @' host.localdomain'用户访问被拒绝

时间:2014-05-02 11:35:50

标签: mysql

我们实验室有三台服务器。这些服务器的主机名是: ABC说。

其中三人安装了MySQL并且工作正常。

问题是:

当我尝试使用以下方式从MySQL连接到计算机B上的A服务器时

mysql -u username -h 10.0.0.230 -p

我收到错误:

ERROR 1045 (28000): Access denied for user 'user'@'B.localdomain'

/etc/hosts的{​​{1}}文件如下:

A

127.0.0.1 localhost 127.0.1.1 A # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 的{​​{1}}文件如下:

/etc/hosts

用户B位于127.0.0.1 localhost B.localdomain 10.0.0.230 A.localdomain 10.0.0.232 C.localdomain 的{​​{1}}数据库中。

出现此类错误的原因是什么?提前感谢任何建议。

2 个答案:

答案 0 :(得分:2)

您必须为用户'user'@'B.localdomain'授予权利,另请参阅documentation for

答案 1 :(得分:1)

您必须更改服务器绑定地址才能连接地址而不是本地地址( localhost )。

所以,例如对于您的机器B,在 /etc/mysql/my.cnf 下,将 bind-adrdess 属性更改为" 10.0.0.231& #34;如下(假设10.0.0.231是B的IP地址):

bind-address        = 10.0.0.231

然后授予 testadmin 用户访问机器B下 mysql 服务器所需的权限:

mysql> GRANT ALL ON `database_name`.* TO 'testadmin'@'A.localdoamin' IDENTIFIED BY 'password';

您可以按照A和C的相同模式。

相关问题