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!