Allow any IP to access the mysql database

Problem description
MYSQL can only connect locally by default, that is, 127.0.0.1 and localhost, and other host IPs cannot access the database, otherwise the following error message will appear:
Host is not allowed to connect to this MySQL server

First, log in to MYSQL locally with the localhost user

mysql> mysql -h localhost -u root -p

2. Query the user table

mysql> select host,user from mysql.user;

3. Set to allow any IP access, execute the statement:

mysql> update mysql.user set host = '%' where user = 'root';

4. Refresh permissions

mysql> flush privileges;

5. You can use ip to log in on other hosts <provided that the network is reachable> <use the ping command to test>

mysql> mysql -h 192.168.1.10 -u root -p -P3306

6. Press win+r to open, enter cmd, quickly open the command line interface, and then enter cmd

ping 192.168.1.10

Guess you like

Origin blog.csdn.net/mengniu666/article/details/129680530