Unable to connect to database MYSQL created in EC2 instance

0

I'm trying to connect to database MySQL that i create in EC2 instance by using Navicat ver.11.2.16 and SQLyog Community ver.13.2.0 and got an error 10061 "Unknown Error"..I also added SQL port into Inbound Rules but still the same. Please help how to connect by using this GUI..

Security Groups - Inbound Rules

KFN1220
asked a year ago3296 views
2 Answers
0

If you are encountering an "Unknown Error" (Error 10061) when trying to connect to a MySQL database hosted on an EC2 instance using Navicat or SQLyog, here are a few troubleshooting steps you can follow:

  1. Verify the EC2 Instance Security Group: Ensure that the security group associated with your EC2 instance allows incoming connections on the MySQL port (default is 3306). You mentioned that you added the SQL port to the inbound rules, but double-check the configuration to make sure it is correctly set up.
  2. Confirm MySQL Service Status: Verify that the MySQL service is running and active on your EC2 instance. SSH into the EC2 instance and check the status of the MySQL service. You can use the following command: sudo service mysql status, If the service is not running, start it using: sudo service mysql start
  3. Check MySQL Binding Address: Ensure that MySQL is configured to bind to the correct IP address. Open the MySQL configuration file (typically located at /etc/mysql/mysql.conf.d/mysqld.cnf) and confirm that the bind-address directive is set to the private IP address of your EC2 instance. If it is set to 127.0.0.1 or localhost, modify it to the private IP and restart the MySQL service.
  4. Verify MySQL User Credentials: Double-check the username and password you are using to connect to the MySQL database. Ensure that they are correct and have sufficient privileges to access the database.
  5. Check Firewall Settings: Confirm that there are no additional firewalls or network-level restrictions (such as Network ACLs in AWS) blocking the connection between your local machine and the EC2 instance.
  6. Test Connectivity with Telnet: Use the telnet command to check if you can establish a network connection to the MySQL port on your EC2 instance. Run the following command from your local machine: telnet <EC2-instance-IP> 3306. If the connection is successful, you should see a blank screen. If it fails to connect, it indicates a network issue or a misconfiguration.
  7. Verify GUI Tool Configuration: Double-check the connection settings in Navicat or SQLyog. Ensure that you have entered the correct host (EC2 instance IP or hostname), port (3306), username, and password. Also, confirm that you have selected the appropriate connection method (e.g., Standard TCP/IP).
  8. Update GUI Tool Versions: Consider updating to the latest versions of Navicat or SQLyog, as older versions may have compatibility issues or bugs.

If nothing of the above point works. Check the MySQL error log on the EC2 instance for any relevant error messages that could provide more insight into the issue. Let me know if this works.

answered a year ago
  • I tried to follow all above suggestion but none working. Here is your result

    1. Confirmed
    2. Active
    3. Tried bind with private IP but failed. Tried also public IP doesn't worked
    4. Deleted and Created new user, but failed during connection
    5. checked ufw but status is inactive
    6. TELNET to private or public IP got Network Error
    7. Failed to connect and still error (Error No. 2002 Can't connect to MySQL server on 'xx.xxx.x.xxx' (10061)
    8. Updated to latest version
0

Maybe you allowed MySQL traffic by using AWS Network ACLs etc. but you need to reconfigure mysql instance also.

The MySQL user that you're using to connect must have privileges to connect from the host where Navicat/SQLyog is running. You can grant these privileges via a command like GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'%' IDENTIFIED BY 'password'; Be cautious with this kind of operation as it might affect the security of your database.

By default, MySQL only listens on localhost (127.0.0.1). To accept connections from remote systems, you need to configure MySQL to listen on 0.0.0.0 or the public IP of your EC2 instance. This is typically done by modifying the MySQL config file (often located in /etc/mysql/mysql.conf.d/mysqld.cnf or /etc/my.cnf), finding the line that says bind-address = 127.0.0.1 and changing it to bind-address = 0.0.0.0. After making this change, restart your MySQL service

profile picture
EXPERT
answered a year ago
  • I tried bind the IP (private and public IP) in /etc/mysql/mysql.conf.d/mysqld.cnf and restart the service plus the tried also reboot the instance but no luck..

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions