1. Error connecting to the database
1.1 Error phenomenon
mysql_real_connect() error: Host '192.168.175.1' is not allowed to connect to this MySQL server
1.2 Reasons
The client IP does not have permission to access the remote database.
Second, the solution
2.1 Modify permissions
Order:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.0.109' IDENTIFIED BY 'love' WITH GRANT OPTION;
FLUSH PRIVILEGES;
meaning:
Let the user whose IP is 192.168.0.109 use the username root and password love to access the database.
If 192.168.0.109 is %, it means that all IP users can use the username root and password love to access the database.
2.2 Modify the table
The access rights of mysql are stored in the user table of the database mysql. You can directly modify the user table of the library mysql to modify the permissions.
use mysql;
select host,user from user;