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.

Records in this category

Tags

top