Can't connect to MySQL server on Amazon RDS - mysql

I've just launched a MariaDB instance on RDS. I used all the default options, on the free tier. It has finished creating. When I try to access it with Sequel Pro or with the command line, I get an error:
Can't connect to MySQL server on {endpoint}
My security group is the default group. Its Inbound and Outbound Rules have:
Type: ALL Traffic
Protocol: ALL
Port Range: ALL
What am I missing here?

The answer for me was to add a new Inbound Rule to my existing Security Group:
Type: MySQL/Aurora (3306)
Protocol: TCP (6)
Port Range: 3306
Source: 0.0.0.0/0
[EDIT Oct 2020]: See Leon's comment below. Instead of 0.0.0.0/0 use your specific IP address.

Does the instance have an internet ip? If not, you know, you can
only connect it from inner net.
The port is 3306?

Related

what is the port 33060 for mysql server ports in addition to the port 3306

background purpose: I want to restrict inbound connection to MYSQL server only for specific host by setting inbound rules of windows firewall.
MYSQL server port is open on 3306.
However, when I open firewall setting, I can see two ports are opened on 3306 and 33060 as follows:
what is that? Should I restrict 33060 as well?
The port for X Protocol (mysqlx_port), supported by clients such as MySQL Shell, MySQL Connectors and MySQL Router, is calculated by multiplying the port used for classic MySQL protocol by 10. For example if the classic MySQL protocol port is the default value of 3306 then the X Protocol port is 33060.
See MySQL Port Reference Tables for more information.
The MySQL X service, is listening on all interfaces, by default over localhost, on TCP port 33060 and clients can connect to it through x protocol. So you need to restrict it for specific host to ban it to connect through x protocol. I suggest use it just for localhost.
You can see open ports by mysql through the following command:
sudo lsof -i -P -n | grep 3306

Telnet works from one network but doesn't work's from another when trying to connect EC2 instance on port 3306

I'm running MySQL server on an EC2 instance on AWS. I've configured security groups to listen at port 3306 and port 22(ssh only from my ip!). But to my surprise, I wasn't able to remotely connect to my ec2 instance on port 3306 from one of my networks as it always gives connection refused, but when I switched my network I'm able to connect.
I'm unable to understand this behaviour as both my networks are working absolutely fine and also I'm not sure if I face similar kind of issue in future, how will I be sure that port 3306 is working?
Only MySQL uses port 3306. You can use netstat command to check if port 3306 is being used or not. Also you can check the firewall rule of the network ( from which you are not able to connect) if something is preventing to connect port 3306. I am assuming that all security inbound and outbound rules are already present.

Accessing rds MySql db with SSL 443 instead of 3306

I am trying to access my rds mySql db via 443 only instead of 3306.
After enabling the ssl option on workbench and entering the path to the mysql-ssl-ca-cert.pem I tried to disable tcp 3306 on my security group to insure it connects using 443 but it doesn't.
I can connect using the mysql command line below but yet again it fails once i disable tcp 443 on the security group
mysql -h myinstance.c9akciq32.rds-us-east-1.amazonaws.com --ssl_ca=rds-ssl-ca-cert.pem
Amazon documentation states:
The SSL support in Amazon RDS is strictly for encrypting the connection between your client and your DB instance; it should not be relied on for authenticating the server.
Does this mean that I can only ever authenticate to mysql db over 3306 and not 443, but the data will be encrypted in transit?
My issue is that my customer won't open 3306 outbound on their firewall but 443 is of course opened. Any help appreciated.
You are confusing SSL and HTTPS. Port 443 is the default port for HTTPS connections. MySQL uses 3306 instead (and can use SSL over this port or any other to encrypt the connection). So, setting up SSL encryption for a MySQL connection doesn't affect the used port.
In order to use a different than the standard port you have to reconfigure the MySQL server, which you probably cannot do with an RDS instance.
It is possible to use tunneling to avoid the default port. In this scenario you have to open an SSH tunnel (MySQL Workbench can do that for you or you use an external program like putty on Windows or ssh on *nix like OSes). With that tunnel in place (which uses port 22 by default but can be configured for any other port if that matters for you) you can then forward access from a local port (here 3306, but can be any) to a remote port (can be any as well). This requires an SSH server on the remote end however.

Cant connect to mysql server on AWS RDS

I am new to AWS RDS. I have created RDS instance.But i dont know, how can i connect this DB.
I tried like this
mysql -h awsinstanamehere.rds.amazonaws.com -P 3306 -u username -p
After i entered password and i am getting some error like this
ERROR 2003 (HY000): Can't connect to MySQL server on
'awsinstanamehere.rds.amazonaws.com' (110)
Need to set any security setting in AWS console?
Note:
I want to import tables for that DB
Thanks
RDS has a security group - in the AWS console, RDS, there's an entry for security groups.
If you didn't explicitly create a security group, you are probably using "default". You should probably have one group per RDS instance.
You will need to make sure that port 3306 is open to your local network, as well as whatever application you will be using to connect to it. You can allow access by IP or by security group.
Same error, but in my case the problem wasn't related to security groups.
I forgot to add an additional route to the route table of the subnets.
See below the 2nd route where the internet gateway was added as the target for all non local traffic (outside the VPC):
I was having a little trouble with these answers so here are the steps I followed to get it working...
Logged in via ssh to my ec2 instance.
typed this command, curl canhazip.com
copied the ip address that was returned
went to my VPC Dashboard in aws
clicked on Security Groups in the left column
clicked on the checkbox next to one of the security groups
clicked Edit under the Inbound Rules tab
added this rule : MySQL/Aurora (3306) TCP (6) 3306 [IP from #2]/32
saved
I did this for every security group until the mysql connection worked from the command line, then deleted all of the ones that I didn't need, and retested to make sure I could still connect.
By default security group defined by AWS is not configured for publicly available inbound source. You will have to modify the security group inbound source ip to 0.0.0.0/0
It worked for me when I added the port 3306, while it was only the 1433 it was not working....
so the security group was created like this
security group vpc-XXXXXX
MY SQL / TCP / 1433 / 0.0.0.0/0
MY SQL / TCP / 1433 / ::/0
MTSQL/Aurora / TCP / 3306 / 0.0.0.0/0
MSSQL/Autora / TCP / 3306 / ::/0
following the headers TYPE / Protocol / Port Range / Source

How can I connect to a MySQL deamon on other host?

I'd like to connect to MySQL (deamon is running on my VPS) via HeidiSQL. I've created new user, commented bind-adress option and when I try to connect with it via HeidiSQL, I've got an error 2003: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (10061).
What should I do?
It could be a number of factors.
See if a firewall is blocking your traffic to the other host
Can you simply ping the host from the client machine?
Can you also open a simple telnet session to the host on port 3306 ?
(If the telnet is accepted, you will probably see some characters appear and you will remain in the telnet session for a few seconds before the connection is closed. If not accepted, you will see the message Connection refused.)
There's a simple checklist for this:
Is your MySQL server bound to "localhost" only? It might be listening for connections only on 127.0.0.1 or ::1 instead of any which is usually 0.0.0.0. Try connecting on your server to your server with mysql --host=host_ip where host_ip is your network IP address. I think the default is localhost-only.
Is port 3306 firewalled? Many distributions allow only SSH by default, so you may need to open this up to your client machine. Try not to open this up to everyone on the internet as having an open MySQL port is asking for trouble. It's always best to limit access to a set of specific IPs if possible.
Can you connect via an SSH tunnel instead? This is far more secure as it means your 3306 port is properly firewalled. There are many tools for creating SSH tunnels, but the basic principle is to forward a local port of your choosing to the remote server's port 3306.