How to access mysql over ssh tunnel


Mysql can be securely access over SSH tunnel.

 

Accessing remote msql server from WIndows via SSH Tunnel

In Windows, mysql connection over ssh can be easily achieved using HeidiSQL software. HeidiSQL could be downloaded from the link given below.

http://www.heidisql.com/download.php

 

 

Accessing remote msql server from Linux via SSH Tunnel if there is NO local mysql server

In Linux, mysql connection over ssh can be opened using 2 bash temrinals.

In "Terminal 1", run following command.

============================
ssh -L 3306:127.0.0.1:3306 <ssh user>@<serverip>
============================

Make sure to replace "<ssh user>" with ssh user name & "<serverip>" with server IP. The command will ask for password of ssh user, please provide it.


In "Terminal 2", run following command

mysql -h 127.0.0.1 -u <mysql user> -p -D "database name"


Make sure to replace "<mysql user>" with mysql user name The command will ask for password of mysql user, please provide it.

 

Accessing remote msql server from Linux via SSH Tunnel if there is a local mysql server running

In Linux, mysql connection over ssh can be opened using 2 bash temrinals.

In "Terminal 1", run following command.

============================
ssh -L 8306:127.0.0.1:3306 <ssh user>@<serverip>
============================

Make sure to replace "<ssh user>" with ssh user name & "<serverip>" with server IP. The command will ask for password of ssh user, please provide it.


In "Terminal 2", run following command

mysql  -P8306 -h 127.0.0.1 -u <mysql user> -p -D "database name"


Make sure to replace "<mysql user>" with mysql user name The command will ask for password of mysql user, please provide it.

Last update:
2016-05-26 08:29
Author:
Bytehouse Technical Support
Revision:
1.8
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Most popular FAQs RSS

  1. I require an additional IPv4 address. What is Bytehouse's ... (87981 views)
  2. The Most Common Problems When Migrating Websites (66436 views)
  3. How do I create a 301 redirect? (55004 views)
  4. Can I Backup Exchange 2010 with My Online Backup ... (53169 views)
  5. Steps to Add Administrator User for Windows Server (48716 views)

Latest FAQs RSS

  1. Steps to set/customize log rotation from plesk (2016-07-25 07:15)
  2. Generate a self-signed SSL certificate - Nginx,CentOS (2016-07-07 02:31)
  3. Procedure re-register Volume Shadow Copy Service(VSS) in a Windows ... (2016-07-05 04:18)
  4. Steps to Install Mcrypt in Plesk (2016-07-01 17:11)
  5. How to Retrieve a Plesk Password in Linux and ... (2016-07-01 17:09)

Regular new KB articles

Check back from time to time for new articles, or if you have any suggestions please feel free to recommend

top