Why am I getting “Host '192.168.1.220' is

2019-06-01 05:32发布

问题:

This question already has an answer here:

  • Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server 24 answers

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

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

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?

回答1:

Probably you have no access rule defined for root@192.168.1.220. Then the server refuses this connection.

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

Here you 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

bind-address = 127.0.0.1

from /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.



回答2:

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

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