Azure Database for MySQL is a fully managed database service, based on the MySQL Community Edition, that runs in the Microsoft cloud. While the service provides features such as patching, backups, high availability, and security, there are some requirements and best practices to understand when you are using the service.
This article lists the most common connection issues that users may encounter, together with suggestions and recommended solutions for addressing those issues.
This detail applies specifically to the Azure Database for MySQL Single Server deployment model.
There can be multiple reasons for this. Please see the following guidance.
Recommended solution: Confirm that the username you are passing ends with the correct server name/hostname field. The username needs to be passed in the format username@servername.
Recommended solution: You can reset the admin password by using the Azure portal. The reset password option in the Azure portal helps recreate the user, reset the password, and restore the admin permissions, which will allow you to log in using the server admin account and perform further operations.
Start by testing the connection from the Azure Cloud shell in the portal to see if you can connect. This can also help determine whether it’s a database availability issue or an issue with your client network.
Server firewall configuration
Recommended solution: Make sure the IP address is allowed on the server Firewall rule and that you are using correct the username format, your_user@servername, and the right password. For temporary testing purposes only, set up a firewall rule using 0.0.0.0 as the starting IP address and using 255.255.255.255 as the ending IP address. This will open the server to all IP addresses. If this resolves your connectivity issue, remove this rule, and create a firewall rule for an appropriately limited IP address or address range.
Client firewall configuration
The firewall on your client must allow connections to your database server.
Recommended solution: Note that the Basic tier does not support VNet service endpoints. You must remove the endpoint Microsoft.Sql from the subnet attempting to connect to the Basic tier server.
It is highly recommended to use only the supported drivers and tools and latest client version. Note that you can’t connect to Azure Database for MySQL using SSMS.
Recommended solution: We highly recommend connection pooling if you have not done it yet and exam your pool configuration. Learn more about this.
Recommended solution: You can start checking if you have increased workload and if you have made any changes to application code as well as server parameters.
Recommended solution: You should reset init_connect value in server parameters tab in Azure portal and use only the supported server parameter. More information can be found here and in this blog post.
Recommended solution: Check out the max_connnections. You can find the limit for each tier in this doc and increase the max_connections. For best experience, we recommend that you use a connection pooler like ProxySQL to efficiently manage connections as mentioned above. If you see unexpected high number of connections, check your application code, and retry configuration as well.
Recommended solution: Consider either expiring and/or testing connection validity before using it in your application. To avoid this issue, increase the server configured values for client timeouts, or use the Connector/J connection property autoReconnect=true to avoid this problem.
This could be because of issue in Azure infra or maintenance activities.
Hopefully, if you've been through all the guidance above, you've identified the cause of the connectivity issue. If you have any questions, please feel free to let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.