Home >Database >Mysql Tutorial >How to modify the resolution of allowed host access permissions in mysql
Enable remote access permissions for mysql
By default, mysql users do not have remote access permissions, so when the program and the database are not on the same server, we need to enable remote access permissions for mysql.
There are two mainstream methods, the table modification method and the authorization method.
Relatively speaking, the table modification method is easier, and I personally tend to use this method. Therefore, only the table modification method is posted here.
1. Log in to mysql
mysql -u root -p
2. Modify the user table of the mysql library and change the host item from localhost to %. %This means that any host is allowed to access. If only a certain IP is allowed to access, it can be changed to the corresponding IP. For example, localhost can be changed to 192.168.1.123, which means that only the IP 192.168.1.123 of the LAN is allowed to remotely access mysql. .
mysql> use mysql; mysql> update user set host = '%' where user = 'root'; mysql> select host, user from user; mysql> flush privileges;
Firewall opens port 3306
The above is the detailed content of How to modify the resolution of allowed host access permissions in mysql. For more information, please follow other related articles on the PHP Chinese website!