为什么我收到“主机‘192.168.1.220’不允许连接到这个 MySQL 服务器”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18158770/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:29:56  来源:igfitidea点击:

Why am I getting "Host '192.168.1.220' is not allowed to connect to this MySQL server"?

mysqlphpmyadmin

提问by user2667314

I need to run MySQL (phpMyAdmin) on a LAN. This is my connection string:

我需要在 LAN 上运行 MySQL (phpMyAdmin)。这是我的连接字符串:

Function Connection() As MySqlConnection
    'Connect Database
    MyConnection.ConnectionString = "server=192.168.1.101;" _
 & "user id=root;" _
 & "password=;" _
 & "database=db1230018;"
    '
    MyConnection.Open()
    Return MyConnection
End Function

I get an error:

我收到一个错误:

Host '192.168.1.220' is not allowed to connect to this MySQL server

不允许主机“192.168.1.220”连接到此 MySQL 服务器

I have two PCs. One of them (Windows 7 - 192.168.1.101) runs a WAMP server (phpMyAdmin) and a VB.NET application using the above connection string. Now I want to run the application on the second pc (Windows) using the same database in 192.168.1.101. I already define a fixed IP on both PCs and disable firewalls. What's going on?

我有两台电脑。其中之一 (Windows 7 - 192.168.1.101) 使用上述连接字符串运行 WAMP 服务器 (phpMyAdmin) 和 VB.NET 应用程序。现在我想使用 192.168.1.101 中的相同数据库在第二台电脑(Windows)上运行应用程序。我已经在两台 PC 上定义了一个固定 IP 并禁用了防火墙。这是怎么回事?

回答by glglgl

Probably you have no access rule defined for [email protected]. Then the server refuses this connection.

可能您没有为 定义访问规则[email protected]。然后服务器拒绝此连接。

Besides, you have to remove the restriction about the bind address in the config file.

此外,您必须取消配置文件中对绑定地址的限制。

Hereyou are told how that works:

这里告诉你它是如何工作的:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

in MySQL and remove the line

在 MySQL 中并删除该行

bind-address = 127.0.0.1

from /etc/mysql/my.cnf.

/etc/mysql/my.cnf.

As you get the said message from the server, it might be that the latter step isn't necessary any longer. Otherwise, you would get a message from the client that it is unable to connect to the server.

当您从服务器收到上述消息时,可能不再需要后面的步骤。否则,您会从客户端收到一条消息,指出它无法连接到服务器。

回答by user2656474

i think you haven't given sufficient privileges to the specified 'root'@'host'

我认为您没有给予指定的足够权限 'root'@'host'

you should look into the user.mysqltable and give sufficient privileges to that particular 'user'@'host'.

您应该查看该user.mysql表并为该特定'user'@'host'.