Mysql settings prohibit remote connections: 1. Log in to the database server and specify the mysql database; 2. Execute the [update user set host='localhost' where user='root';] statement; 3. Refresh permissions surface.
Specific steps:
(Recommended tutorial: mysql video tutorial)
use mysql #打开mysql数据库 #将host设置为localhost表示只能本地连接mysql update user set host='localhost' where user='root'; flush privileges; #刷新权限表,使配置生效
If we To enable remote connection, you can refer to the following method:
First log in:
mysql -u root -h localhost -p
use mysql #打开mysql数据库#将host设置为%表示任何ip都能连接mysql,当然您也可以将host指定为某个ip update user set host='%' where user='root' and host='localhost';flush privileges; #刷新权限表,使配置生效
After completion, we can connect to our mysql remotely.
Related recommendations: php training
The above is the detailed content of How to set up mysql to prohibit remote connections. For more information, please follow other related articles on the PHP Chinese website!