Linux - CentOS7.0 opens a remote connection to Mysql database

By default, you cannot use the client to connect remotely. The help.docx provided by Alibaba Cloud provides setting instructions. The mysql password is stored by default.

 

First login: mysql -uroot -p

enter password

use mysql #Open mysql database

 

#Set the host to % to indicate that any ip can connect to mysql, of course you can also specify the host as a certain ip

update user set host='%' where user='root' and host='localhost';

flush privileges; #Refresh the privilege table to make the configuration take effect

Then we can connect to our mysql remotely.

 

If you want to close the remote connection and restore the default settings of mysql (only local connection), you can do it by the following steps:

use mysql #Open mysql database

#Set host to localhost to indicate that you can only connect to mysql locally

update user set host='localhost' where user='root';

flush privileges; #Refresh the privilege table to make the configuration take effect

 

Note: You can also add a remote connection user whose user name is yuancheng, password is 123456, and permission is % (meaning that any ip can connect). The command reference is as follows:

grant all on *.* to 'yuancheng'@'%' identified by '123456';

flush privileges;

 

Original address: http://my.oschina.net/ecnu/blog/29530

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326944280&siteId=291194637