Connect Remotely to mysql running on a Amazon EC2 Instance - mysql

I'm trying to connect MySQL Workbench to an Amazon EC2 (Linux) instance that hosts a MySQL Database. (Not RDS but localhost). However for some reason, I can't get it to connect remotely.
Things Ive done:
- Set the security group to allow any IP to access port 3306
- Created a mysql user and granted all privledges on it.
- Modified the my.cnf to include bind-address=0.0.0.0 However i still cant connect.
On this instance I do have SSL cert installed and I am forwarded all http request to https?.. But im not sure if this has anything to do with it.
If anyone could guide my in the righ direction I would appreciate it.

I would personally give it an Elastic IP so it will have a public IP, then bind the mysql to that IP. Make sure the iptables are set to accept the mysql connections. I also wouldnt suggest leaving mysql open to every ip unless this is an absolute necessity.

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

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.

SSH tunnel to MySQL database

We're in the process of setting up Tableau connectivity to our company's sales database and so far, the people that have been attempting to connect (they're from some other company) keep getting denied. The errors they're getting are as follows.
Unable to connect to the ODBC Data Source. Check that the necessary drivers are installed and that the connection properties are valid.
Can't connect to MySQL server on '[IP address] (61).'
Unable to connect to the server '[IP address].' Check that the server is running and that you have access privileges to the requested database.
Today we opened ports 3306 and 20560. We were hoping we could set up some kind of port forwarding thing so that they connect to 20560. I'm not sure what we need to do to set that up, however. I was also told that SSH tunneling is an option, but connecting with PuTTY doesn't yield any results.
I'm at a complete loss as to what I need to do to allow them to connect. I'm also not sure that opening port 3306 is safe and I'd like to know if I should have it closed. I randomly picked port 20560 because it's not being used for anything. We don't want just anyone to connect, but I've been told that the IP address connecting to our database may not be static.

Connecting MySQL on EC2 to Tableau

I used a quick start guide to create a mysql database on EC2 that I can access and query using RStudio. However, I'd like to use Tableau Desktop to visualize the data as well. Tableau can connect to MySQL, but Im not sure how to make it work with EC2. I think I need to use port forwarding. I've Googled extensively and found a few examples but I'm completely new to this and don't know where to begin.
I'm using Terminal on Mac OSX. I'm able to login to SSH and to MySQL once in SSH.
Tableau needs a server, port, user, pass, and initial SQL statement. I'm assuming the initial SQL statement is just "use MyDatabase;"
I remember running into this issue awhile ago and found the solution again. I think the main thing to remember is that you have to use the localhost as the address in Tableau after you ssh into EC2 instead of the address of the actual EC2. You also have to setup your ssh to forward the port as you mentioned. Here is how you do that with PuTTY.
In the first screenshot you will see I added 127.0.0.1:3306 as the destination. This is the address of MySQL as setup on your server. I included 9990 as the source port. This is the port that PuTTY will be monitoring for any given calls. Once you have these defined click add and then save your session and connect with your server credentials through PuTTY. Go to Tableau.
In the second screenshot you will see that I used 127.0.0.1 for the server and 9990 for the port that I defined in PuTTY. You then add the credentials in Tableau that correspond to your MySQL user that is setup on EC2.

Connecting MySQLWorkbench to Amazon Web Services EC2 Instances

I have no idea how to connect mySQL to amazon EC2 Instance. Here is the screenshot of mySQL workbench: mySQL. I try to change the HostName to the Public IP being provided by the instance, however when i press test connection, it keep promoting this error: Error Message. So what should i do as of now? Thanks!!
Since I cannot put a comment, pardon me for putting this to the
Answers Section
Error 10060 is a generic error that means your client cannot reach the server.
Try pinging your server IP, if it responds, it is online.
Are you sure that the port that EC2 uses is also 3306? Configure your EC2 Instance to allow remote connections. Check the EC2 Security features, something might be blocking you.
AFAIK, the root user is only limited to localhost. So it won't work if you use it remotely. Create a new user with the privileges that you only need, then use the '%' wildcard which means any host.
And finally, you may want to try this: Step by Step instructions
In your EC2 instance you will have a Security Group Column.
Click on that will open the security group page
In the bottom of the page you have a tab called Inbound
Click Edit and then Add Rule to allow port 3306.
In source select anywhere option.