Share via

I am unable to connect with mysql database

Divya Mahajan 0 Reputation points
2026-03-09T10:22:10.0266667+00:00

I am unable to connect with mysql database, kindly help.

Azure Database for MySQL

2 answers

Sort by: Most helpful
  1. Pilladi Padma Sai Manisha 6,665 Reputation points Microsoft External Staff Moderator
    2026-03-09T19:49:55.01+00:00

    Hi Divya Mahajan,
    Welcome to Microsoft Q&A, and thank you for your question.

    If you are unable to connect to the MySQL database, please verify that the server name, port (default 3306), username, and password are correct. Also ensure that your client IP address is allowed in the MySQL server firewall rules.

    Make sure the MySQL server is running and accepting connections. If the database requires SSL, confirm that SSL is enabled in your connection settings. You can also test network connectivity from your machine by checking whether the server and port are reachable.

    If the issue persists, please share the exact error message, the tool you are using to connect (such as MySQL Workbench, CLI, or an application), and whether the MySQL server is hosted locally or on a cloud service. This information will help the community assist you further.

    0 comments No comments

  2. Q&A Assist
    2026-03-09T10:22:34.05+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Use the error code or message from the MySQL client to narrow down the cause, then apply the matching fix.

    1. Check DNS and server name
    • If the error is similar to ERROR 2005 with messages like EAI_SYSTEM, ETIMEDOUT, or name unknown, the issue is DNS resolution on the client side, not Azure Database for MySQL.
    • Use nslookup or dig from the client on the Azure MySQL server name (for example, yourserver.mysql.database.azure.com).
    • If the name does not resolve, correct the server name in the connection string or fix the client DNS configuration.
    1. Check network/firewall and routing
    • If the error is ERROR 2003 (110) "ETIMEDOUT - Connection timed out", there is a timeout to the IP address.
      • Verify firewall rules or NSGs allow outbound traffic from the client to the server on port 3306.
      • Verify any VPN/peering or routing so the client has a path to the Azure MySQL subnet.
      • From the client, test TCP connectivity with tools like nc, telnet, or tcptraceroute to server:3306.
    • If the error is ERROR 2003 (113) "EHOSTUNREACH - Host unreachable", the client routing table does not have a path to the server network.
      • Fix the client network configuration or routing so it can reach the Azure MySQL endpoint.
    1. Check port, host, and service state
    • If the error is ERROR 2003 (111) "ECONNREFUSED - Connection refused":
      • Confirm the hostname and port (default 3306) are correct in the connection string.
      • Ensure the Azure Database for MySQL Flexible Server instance is in the “Running” state in the Azure portal.
      • Use nc/telnet/TCPtraceroute from the client to verify that port 3306 on the given host is accepting connections.
    1. Handle errors after connection is established
    • If the error is ERROR 1045 "Access denied for user":
      • Verify username and password are correct.
      • Confirm the user exists in MySQL and has permissions for the database.
    • If the error is ERROR 2013 "Lost connection to MySQL server" or ERROR 2006 "MySQL server has gone away":
      • This indicates the connection was established but then dropped.
      • Possible causes include connecting to a non-MySQL service on that port, server-side issues, or timeouts.
    • If the error is ERROR 1040 "Too many connections":
      • The server has reached its max connections; reduce client connection usage or increase the max connections setting.
    • If the error is ERROR 1129 "Host 'x.x.x.x' is blocked because of many connection errors":
      • An admin must connect and run FLUSH HOSTS; to unblock the client host.
    1. Next steps
    • Identify the exact MySQL error code and message from the client.
    • Match it to the tables below and apply the corresponding troubleshooting steps.
    • If the issue persists after DNS, network, and credential checks, review Azure networking (VNet integration, private endpoints, NSGs, firewalls) for misconfiguration.

    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.