Friday, January 27, 2012

Connect to a MySQL database through an SSH tunnel

I recently signed up to the Amazon EC2 service and I was testing it- so far it looks very good. I didn't yet test the RDS service Amazon offer for MySQL. However I installed MySQL in the EC2.

In this post I will show how to connect to a MySQL database on the EC2 server (this should work with any remote server) and the Navicat MySQL client (great piece of software BTW).

  1. Open a new connection tab in Navicat (or any other MySQL client supporting connection via SSH tunnel. The default MySQL query browser doesn't support this).
  2. Enter the following parameters. Replace the user and password with your login details for the MySQL database on the server. Leave the server name as localhost, this is the host that the client will connect to once connected to the server.


3. Now go to the SSH tab. 
Enter the following parameters:
Host name/ IP address: this is the public DNS name of your server/ server instance or its IP/ EIP
Port 22
Username: user for your server
Authentication metod: Public key in case of the EC2 instance
Private key: load up your private key
Passphrase: empty for the EC2 connection

-> OK. And voila. Enjoy

2 comments:

  1. If I get the error code "80070007: SSH Tunnel: Authentication failed "
    How could I solve this problem or anything I didnt set?
    thanks very much!!!

    ReplyDelete
  2. I have the same problem, Have you solved this problem?

    ReplyDelete