A security group is a collection of access control rules for ECSs and DB instances that have the same security requirements and are mutually trusted in a VPC. To ensure database security and reliability, you need to configure security group rules to allow specific IP addresses and ports to access DB instances.
Check whether the ECS and DB instance are in the same security group.
The default security group rule allows all outgoing data packets. If an ECS and a DB instance are in the same security group, they can access each other. When a security group is created, you can configure security group rules to control access to and from DB instances in that security group.
To ensure the security of your data and DB instances, you are advised to use the principle of least privilege for database access. Change the database port (default value: 3306), and set the IP address to the remote server's address or an IP address on the remote server's smallest subnet so that access to the remote server is limited.
If you use 0.0.0.0/0, all IP addresses are enabled to access DB instances in the security group.
In the Network Information area on the Basic Information page, click the security group.
Parameter |
Description |
Example Value |
---|---|---|
Protocol & Port |
Network protocol for which the security group rule takes effect.
|
TCP |
Port: Port or port range over which the traffic can reach your ECS. |
When connecting to the instance through a private network, enter the port of the instance.
|
|
Source |
Source: specifies the source of the security group rule. The value can be another security group, a CIDR block, or an IP address. xxx.xxx.xxx.xxx/32 (IPv4 address) xxx.xxx.xxx.0/24 (subnet) 0.0.0.0/0 (any IP address) |
0.0.0.0/0 |
Description |
Provides supplementary information about the security group rule. This parameter is optional. The description can contain a maximum of 255 characters and cannot contain angle brackets (<>). |
- |
Operation |
You can copy or delete a security group rule. If there is only one security group rule, the security group rule cannot be deleted. |
- |