Mysql 5.7 open remote connection

After MySQL is installed in the CentOS system, users cannot connect to the database server through a non-local machine by default. The following is the solution:

1. Execute on the console

mysql -uroot -p

The system prompts you to enter the password of the database root user. After entering the password, you will enter the mysql console.

2. Select the database

use mysql;

Open remote connection 
root username 
% everyone can access 
password password

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES; 

3. Restart the mysql service

service mysql restart

If you still cannot connect remotely after performing the above steps, then we need to check whether the firewall of the server is turned on.

service iptables status

If the firewall is on, turn it off

service iptables stop

Now you can connect remotely!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325668904&siteId=291194637