First login: Mysql-u root-h localhost-p
Use MySQL #打开mysql数据库
#将host设置为% means that any IP can be connected to MySQL, but you can also designate host as an IP
Update user set host= '% ' where user= ' root ' and host= ' localhost ';
Flush privileges; #刷新权限表 for the configuration to take effect
Then we can connect to our MySQL remotely.
3, if you want to close the remote connection, restore the default MySQL settings (only local connection), you can do the following steps:
Use MySQL #打开mysql数据库
#将host设置为localhost表示只能本地连接mysql
Update user set host= ' localhost ' where user= ' root ';
Flush privileges; #刷新权限表 for the configuration to take effect
Note: You can also add a user named Yuancheng, with a password of 123456, and a permission of% (indicating that any IP can connect) to a remote connection user. The command reference is as follows:
Grant all on * * to ' yuancheng ' @ ' percent ' identified by ' 123456 ';
Flush privileges;
Server MySQL allows remote connection