RDS for MySQL DB Instance Inaccessible
Scenario
When the MySQL client attempted to connect to a database, the following error information is displayed:
- Fault 1
ERROR 1045 (28000): Access denied for user 'root'@'192.168.0.30' (using password:YES)
- Fault 2
ERROR 1226 (42000): User 'test' has exceeded the 'max_user_connections' resource (current value:10)
- Fault 3
ERROR 1129 (HY000): Host '192.168.0.111' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
Fault 1
- Check whether the password of user root is correct.
ERROR 1045 (28000) is usually caused by an incorrect password so you need to check the password first.
select password('Test1i@123'); select host,user,Password from mysql.user where user='test1';
An incorrect password will cause a login failure as shown in the following figure.
- Check whether the ECS or device has the permission to connect to the DB instance.
select user,host from mysql.user where user='username';
If you want to log in to the database from another ECS or device, log in to the database as user root and grant the permission to the user.
For example, if the IP address of the ECS or device is 192.168.0.76, run the following command:
GRANT all privileges ON test.* TO 'test1'@'192.168.0.76' identified by 'Test1i@123';
flush privileges;
- Check whether the RDS for MySQL client can ping the virtual IP address of the DB instance and use telnet to check the connection to the port.
If the ping and telnet operations are successful, ERROR 1045 (28000) is not caused by the virtual IP address or port of the DB instance.
- Check the security group and rules of the DB instance.
- Query the user table and check user information.
The command output indicates that there are two root users.
When the client is in the network segment 192.168.***.***, RDS for MySQL authenticates the user root@'192.168.%'. However, if the password is root@'%', there will be a login failure. ERROR 1045 (28000) is caused by an invalid password.
User root@'%' is used for setting a password when you create a DB instance on the RDS console.
Fault 2
- Check whether the max_user_connections option is set when you create an RDS for MySQL user, which limits the number of connections.
select user,host ,max_user_connections from mysql.user where user='test';
The command output indicates that the connection failed because the max_user_connections option was used.
- Increase the maximum number of connections for the user.
alter user test@'192.168.0.100' with max_user_connections 15
- Query the modification result and check whether the database can be connected to.
Fault 3
- Check whether the number of failed connection attempts (not caused by incorrect passwords) of the RDS for MySQL client exceeds the value of max_connection_errors.
- Log in to the MySQL database as user root and run flush hosts.
Alternatively, run the following command:
mysqladmin flush-hosts –u<user> –p<password> -h<ip> -P<port >
- Use the MySQL client to connect to the database again.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot