Avatar of jxbma
jxbmaFlag for United States of America

asked on 

How do I connect local MySQL Developer Workbench to remote AWS hosted MySQL database?

Hi:

I'm trying to connect my local (windows based) desktop copy of MySQL Developer workbench to a MySQL DB hosted on AWS (EC2 instance).

AWS/MySQL is set up such that I can connect to the database via phpMyAdmin.
So, I'm assuming that the AWS version of MySQL is set up for remote access.
I'm not fond of using phpMyAdmin's web-based interface.

What are the steps I need to do connect to the AWS MySQL DB through my desktop version of Developer Workbench. I know that I've been able to get this working in the past.

Thanks in advance for your time.

JohnB
MySQL ServerCloud ComputingWeb DevelopmentAWS

Avatar of undefined
Last Comment
Shalom Carmel
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

See if phpMyAdmin shows you an IP address for the MySQL server.  Try using that along with your username and password.  Note that if your only login is for 'localhost', you will not be able to make a remote connection.
Avatar of jxbma
jxbma
Flag of United States of America image

ASKER

This is how I access the AWS based MySQL DB through phpmyadmin:

https://generatedname.mx1.ch/phpmyadmin/

I don't explicitly see any reference to an IP address.

On a previous project, I believe I was able to copy/paste the URL into the Hostname field of the Manage Server Connections dialog.

I looked at the MySQl--> my.cnf file on the server.
It doesn't look like it's got external access turned off.
The port number is the same.

How do I proceed?

Thanks,
JohnB

JB
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

On the main page in phpMyAdmin, there is a line showing the 'server' and another showing the 'user'.  MySQL users are defined by username, password, and access method.  Many places only allow 'localhost' access as a means of preventing unwanted external access.

In the link below, 'monty'@'localhost' and 'monty'@'%' are two different users although we often set them up with the same password.  'monty'@'%' is allowed to connect from anywhere but 'localhost'.  And 'monty'@'localhost' is Only allowed to connect from 'localhost' and Not remotely.  'monty'@'%' can also be 'monty'@'12.34.56.78' which is some specific IP address.

http://dev.mysql.com/doc/refman/5.6/en/adding-users.html
Avatar of jxbma
jxbma
Flag of United States of America image

ASKER

OK. So I added a new user called root to the MySQL DB through phpmyadmin:

I used the following commands:

CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

Open in new window


I still get the following error message:
"Failed to Connect to MySQL at https://generatedname.mx1.ch:3306 with user root"
Unknown MySQL server host 'https://generatedname.mx1.ch' 

Open in new window


If I look at the user table the privilege columns look pretty much the same as what I see for  "user@localhost".

I think the my.cnf file looks OK.
I've attached a copy of it to this comment.

Since I have admin privileges on the VM and in MySQL, I should be able to set this up correctly?

OK, so within the my.cnf file, I see the following line:
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1

Open in new window


Uhg.
What am I doing wrong here?
I'm assuming I somehow need to change/disable this  to something and restart the MySQL Server?

Thanks,
JohnB
my.cnf.txt
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Yes, change it to '0.0.0.0' to allow any IP to access the server.  It is Strongly recommended that you do not allow 'root'@'%'.  'root' has all privileges on all setting on all databases on the server and it is considered very insecure to allow remote access for 'root'.

Info on the bind-address here: http://dev.mysql.com/doc/refman/5.6/en/server-options.html
Avatar of jxbma
jxbma
Flag of United States of America image

ASKER

Hey David:

This is a dev instance, so I'm not quite as worried about security right now.

Questions:
--------------

1) I stopped/started the MySQL service, changed the bind address to 0.0.0.0,
    I still can't connect. It's not recognizing the server host.

2) Should I be creating my MySQL Workbench connection using Standard (TCP/IP) or Standard TCP/IP over SSH? (I do have a ppk key file that I use to connect to basic AWS instance with WinSCP and PUTTY)

3) Regarding the "root" user. Should I create a different user with @'%'?

At this point, I really, really want to get this up and functional for development purposes.

Thanks,
JohnB
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

I would use Standard without SSH.  SSH requires you to set up tunneling and that just complicates things at the moment.  And yes, a different user with @'%'.

While it won't do anything but test the connection, you can try 'telnet' to that server on port 3306 just to see what response you get.  The firewall on the server or network could still be blocking access.
Avatar of jxbma
jxbma
Flag of United States of America image

ASKER

OK. Cannot connect to that server on port 3306 via telnet.
How do I tell which end is blocking?
I looked @ event logs on windows 7 machine and don't see anything there.

JB
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

It is almost certainly the remote server because (at least for Windows firewall), outgoing connections are almost always permitted.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Shalom Carmel
Shalom Carmel
Flag of Israel image

You must grant ingress access to your IP address (or to the world) in the EC2 security group associated with your server.
Web Development
Web Development

Web development includes all aspects of presenting content on intranets and the Internet, including delivery development, protocols, languages and standards, server software, browser clients, databases and multimedia generation.

77K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo