ERROR 2003 (HY000): Can't connect to MySQL server on AWS RDS - mysql

I created an external user with '%' hostname to allow remote access. I get the following error while connecting the local MySQL to remote AWS RDS:
ERROR 2003 (HY000): Can't connect to MySQL server on 'instance.cvxqy8tbi2bk.us-east-1.rds.amazonaws.com' (110).
I tried commenting the #bind-address = localhost but no solution.
Any pointers for this?

Anyone encountering this issue today should check out this YouTube video at around 6:05:
AWS RDS MySQL Database Setup | Step by Step Tutorial.
In a nutshell, you have to create a new inbound security rule to allow an external connection.

I had the same problem.
this solution: When you create database
in the Virtual private cloud (VPC), please choose "Create new VPC"
in the VPC security group, please choose "create new", don't choose "choose existing"

You should diagnose connection to ANY Mysql/Mariadb/RDS connection before changing any server parameter.
Always use this to check connection.
mysql -u username -p -h your_rds_instance_name
If connection fail, then check network connection(can you ping the instance name from your local system? ), i.e. firewall access, RDS Subnet rules, security groups rules. If the topics too advance for your, then follow the usual quickstart guidelines and tutorial.

"I tried commenting the #bind-address = localhost but no solution. "
No you cannot just comment it out.
If you want to allow remote connections to the MySQL database then you need to bind to your network adapter and not localhost / the loopback adapter.
So you need to get your server IP then:
bind-address = the.srv.ip.is
This is a better question for Server Fault ;)

I faced the same issue, turns out that I had made the database private to the VPC, meaning only instances in the vpc would be allowed to access the databse,
so either make the DB public or try to access the database using an instance in your VPC.

change settings to Publicly accessible. by clicking Modify option

Related

Can't connect to mysql database outside aws vm after creating succesfully

I followed this article to setup mysql server in my aws vm. At the time of creation of the vm itself I had allowed inbound traffic to port 3306 from all ip addresses.
After creating an admin account, I cannot access the account from outside the vm using sql workbench. I made changes in the property file to change the bind-address to 0.0.0.0 so that remote connections maybe allowed from outside. That also did not help.
What am I missing here? I did everything and still it won't connect. Appreciate any help on the matter.
AWS Security Groups
Based on the comments.
The issue was that mysql was setup to allow access from localhost. To solve the problem, external access needed to be allowed. This can be done by following the guide:
How To Allow Remote Access to MySQL

Why can't I connect to AWS RDS?

I'm trying to connect to my new AWS RDS I just made.
I followed the "Setting up for RDS" (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_SettingUp.html), then the "Tutorial: Create an Amazon VPC for Use with a DB Instance" (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateVPC.html), then the "Creating a MySQL DB Instance and Connecting to a Database on a MySQL DB Instance" (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.MySQL.html) but I'm not able to connect to my DB from my computer or my dedicated server on the web.
Following the previous docs, I have this config :
My DB instance
The VPC
The subnetworks
Example of subnetwork's details :
The first security group :
The second security group, calling the first one :
For the first security group, I put both my private IP and the IP of my dedicated server, and their ports.
I even tried to put 0.0.0.0/0 for SSH and TCP, it didn't work either.
For the DB instance, I tried to add the two security group instead of only the db-securitygroup, it didn't work.
I tried to use a different Port for the DB instance, it didn't work.
With MySQL Workbench or with PDO on my dedicated server, I'm unable to connect to the DB : "SQLSTATE[HY000] [2003] Can't connect to MySQL server on [...]"
I think your security groups are incorrect. If the RDS instance is the only thing you currently have running in the VPC, then you should only have one security group, which is assigned to the RDS server, and that security group should have a rule for port 3306 that allows ingress from your personal IP address, and your dedicated server's IP address.
Take a look to this instruction, pay attention to step 3, 4 and 5. It is for ElasticSearch but I think in your case steps are similar

I am not able to connect to mysql server running on Google Compute engine from another instance using internal IP

I located the /etc/mysql/my.cnf file
I changed the bind-address
first to 0.0.0.0 I received a '111 Connection refused'
then I changed it to the instance I am trying to connect to It still says '111 Connection refused'
the firewall rule allows connection on port 3306 using internal ip so I dont know the problem. Thanks
It seems that you have already taken the necessary steps to connect to MySQL server from GCE your instance. Based on the Stackoverflow case here the recommendation to resolve this problem is to comment this line below (add # at the beginning of the line) in your my.cnf file:
skip-networking
Once done you need to restart MySQL service
sudo service mysql restart
On the GCP side, if you have allowed the IP ranges you want to use with the specified port(3306), it should work fine.
You can also use “nmap” command to verify if port 3306 is open on your GCE instance with MySQL installed.
GCP provides CloudSQL which is a managed MySQL instance. You can access CloudSQL from your GCE VM using private address. This feature reached beta recently. This link provides detailed information about using private IP to connect to your Cloud SQL instances.
Before configuring a Cloud SQL instance to use private IP, you need some steps to be taken. This document provides step by step instructions for configuring an instance to use private IP.
You can use 'netstat -tunlp | grep 3306' command to verify that the MYSQL process is running on port 3306.
This error can also occur when mysql user account does not accept connections from any IP addresses. It may still use localhost parameter to connect to the server. I would recommend adding a user with remote access or granting existing user access to remote sources. You can see this: link for the similar issue and follow the steps recommended there to resolve.

Connecting to Amazon RDS MySql remotely

I'm trying to connect to MySql on Amazon RDS from my computer, using MySql WorkBench, or HeidiSql or even the console Mysql.exe and i'm getting this error all the time:
ERROR 2003 (HY000): Can't connect to MySQL server on 'MY-SERVER-NAME' (10060)
In the Security group of the instance I created a new Inbound rule that allows all traffic, and applied it, and still - same error.
I have no active Firewall on my computer, and have good internet access
I am able to access the DB from the Amazon EC3 server, there I am connecting using HeidiSql, and the exact same settings (host, username, password) is just not working on my computer
Still, nothing is working. I'm pretty sure that my security groups is configured to allow outside connections, as can be seen on the next screenshot, there is another place with firewall rules?
I was having the same problem when using an RDS instance on a VPC that I wanted to connect to remotely. To fix the problem, I needed to do the following:
Go to the VPC Management Console in AWS
Go to Internet Gateways (on the left side)
Create and attach an internet gateway to my VPC. Make note of the ID of this gateway.
Go to Route Tables
Edit the route table associated with the subnets associated with your RDS instance
Add a route:
Destination: 0.0.0.0/0
Target: ID of your Internet Gateway
I didn't have this route in my table because I created my VPC manually and without using the wizard, but if you use the wizard it creates this route for you automatically.
Note: This assumes that your security groups are already configured to allow your IP to connect.
The 2003 error is the Access-Denied Error I would be willing to bet that you haven't configured the RDS to accept your IP address.
This can be done by going to DB Security Groups -> Click Default -> and add a new CIDR/IP range. I believe that if you set it to 0.0.0.0/0 it will accept all ip addresses
I use SQLyog for connecting to Amazon RDS from my machine.
You can refer this blog: http://blog.webyog.com/2009/11/06/amazon-rds-the-beginners-guide/
The security group settings are just firewall rules. If you can telnet on your configured MySQL port from the host you are having problems then you don't have the security group issue.
Chances are the MySQL grants are not allowing outside IPs. If you know the root user/password and you can use it to connect from your EC2 instance that works, make sure the user you are using to connect from outside has the right privileges. Here is the doc on how to add a new privilege or create a new user:
http://dev.mysql.com/doc/refman/5.1/en/grant.html
http://dev.mysql.com/doc/refman/5.1/en/adding-users.html
http://dev.mysql.com/doc/refman/5.0/en/access-denied.html
Did you assign the security group to your RDS instance? If you didn't modify the default security group, then you need to add your security group to your RDS instance.
In my case, my company had two different network connections. When I went to google and searched "What is my IP?" I got one answer; 209.x.y.z. When I went to checkip.amazonaws.com I got another answer; 199.a.b.c.
I had already added VPC Security Group Rules for 209.x.y.z and it turned out I needed them for 199.a.b.c.
Adding rules for 199.a.b.c fixed the issue.
I had same problem as you, all firewall have been opened, but still can not access to my RDS mysql remotely from my local machine. my finally workout is there is a "Public Accessibility" option on your RDS database. default is "No", after I tick it to "YES", everything is running smoothly now.

VB.net - Connect to Database

I got mysql database in the phpmyadmin, and i try to connect to the database from my application.
My connection string is:
Server=12.919.18.12;Port=3306;Database=hbd;Uid=hb;Pwd=123;
An exception occurs:
"Unable to connect to any of the specified MySQL hosts."
Do I need to install mysql or something?
(I just imported MySql.Data.dll and tryied it. Is there anything I have forgotten? I checked the ip pinging my website).
Connection strings for MySQL
is pretty helpful in terms of connection strings. Your connection
string seems to be invalid.
You may check mysql server is working or not and you can add port number of mysql in connection string like this
"Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;"
Other reason MySql might be configured to listen to only the local host.
Follow the following links for more information:
Enabling MySQL Remote Access - MySQL connection only works from local machine
Unable to connect to any of the specified MySQL hosts.
IP is invalid 12.919.18.12
Server=12.919.18.12;Port=3306;Database=hbd;Uid=hb;Pwd=123;
IP block is < 256
If the datababase is local, try localhost or 127.0.0.1 as the IP address.
Is the server on your network? If so, the IP is invalid. If I were you, I'd try to check the IP with the person who gave it to you.
the connection string is correct but as ive read a lot of forums they all have the same problems as you do. my solution is that if your trying to create a network base system on a LAN type network you should use XAMPP or WAMPP but i prefer xampp and double check if your accounts or users have an Admin or any other user name for your connection and then see if they have granted all the privileges and with password of course.
Here is the ff instructions:
Open Xammp
Then open a web browser then open 127.0.0.1 or localhost.
click phpmyadmin then at the top click privileges.
add user and make it sure allow all privileges and check all access.
then connect again using the same connection string with the proper user and password.
This issue is RESOLVED :)
try to put the PORT in the end like :
"Server=12.919.18.12;Database=hbd;Uid=hb;Pwd=123;Port:3306;"