mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.22k stars 2.53k forks source link

Is option to connect to DB through SSH ? #2473

Closed amrsa1 closed 3 years ago

amrsa1 commented 3 years ago

Is there any feature through which i can connect to the server through SSH then initiate a connection to the running DB on that server.?

dougwilson commented 3 years ago

Hi @Amrkamel1 yes, this module just makes a TCP connection to the server like most programs. If you want to connect to something over a SSH connection, just set up SSH port forwarding as usual and then point this module at the local port and localhost. I hope that helps!

amrsa1 commented 3 years ago

Definetly it helps, could provide any reference that could work with mysql.

I have tried many node packages but failed to do so always getting timeout

dougwilson commented 3 years ago

Hi @Amrkamel1 no problem! Here is an example for how to set up a tunnel with the SSH program (the most common way): https://www.ssh.com/ssh/tunneling/example