MySQL is installed on Alibaba Cloud ecs but cannot be accessed from the external network
Steps
Use yum to install mysql server
Start mysql
grant a user to allow access to all hosts
Restart mysql
This is the user table in the mysql library
mysql> select host,user from user;
+-------------------------+---------+
| host | user |
+-------------------------+---------+
| % | dbadmin |
| %.%.%.% | icyfc |
| 127.0.0.1 | root |
| iz8vb8il84z4prxo5ljzqjz | |
| iz8vb8il84z4prxo5ljzqjz | root |
| localhost | |
| localhost | root |
+-------------------------+---------+
[root@iZ8vb8il84z4prxo5ljzqjZ ~]# netstat -tunpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2630/php-fpm
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 32007/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2805/nginx
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 15354/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1555/master
udp 0 0 172.26.13.175:123 0.0.0.0:* 1464/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 1464/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 1464/ntpd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1060/dhclient
[root@iZ8vb8il84z4prxo5ljzqjZ ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:mysql
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
I usually use the management panel Cloud Helper to assist in the installation and deployment of the database MySQL. The environment is deployed with one click and it is also very convenient to manage the MySQL database, including database creation, modification, permission settings, backup and recovery. You can try Cloud Helper https://www.cloudx.cn/?utm_source=wup
Mainly do the following 3 steps, hoping to increase your reputation :)
Each ECS has a security group firewall. First, please check whether the 3306 tcp access 0.0.0.0/0 in this place is ok?
Then check the host == % of the logged in user? (You can refresh the permissions first)
3. Check whether it is blocked by the system’s built-in firewall
Is mysql running on the 0.0.0.0 address?
Whether the firewall and security group allow ports
Whether the mysql user has been granted remote access permission
It is recommended to use ssh proxy to access the database, which is safer
Is it accessed by domain name or IP? If it is a domain name, just authorize it directly. The IP must be based on the actual one and cannot be obtained randomly
Could it be because the Alibaba Cloud security group settings do not allow the port to pass
Alibaba Cloud will limit the IP address range for access for security reasons. You can authorize your external network IP or IP range. Try not to set it to full network access, which may cause security issues.