1. Port 3306 is not enabled?
Run the nestat command to view the status of port 3306:
~ # Netstat-an | grep 3306
Tcp 0 0 127.0.0.1: 3306 0.0.0.0: * LISTEN
The result shows that Port 3306 only listens to the IP address 127.0.0.1, so access from other IP addresses is denied.
1. Change the/etc/mysql/my. cnf file, find bind-address = 127.0.0.1, comment it out, or change it to the ip address that is allowed to access.
2. sudo service mysql restart mysql
3. netstat-an | grep 3306: check the port status. If tcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN is displayed, the modification takes effect.
4. Execute the mysql authorization statement:
The code is as follows: |
Copy code |
1 grant all privileges on *. * TO 'user' @ '% 'identified BY 'password' with grant option; |
*. * Indicates authorizing all databases, and % indicates the authorized ip address (% indicates that all IP addresses are accessible ). Database_name, user_name, and user_password are set based on the actual situation.
5. The remote connection test is successful.