Posts

How to connect to MySQL via SSH tunnel in Windows ?

Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

 How to connect to MySQL via SSH tunnel in Windows ?


To connect to MySQL via an SSH tunnel in Windows, you will need to have an SSH client and MySQL client installed on your computer.

Here are the steps to set up an SSH tunnel and connect to your MySQL server:

  1. Open your SSH client and connect to the remote server where your MySQL database is hosted.

  2. Once you are connected to the server, you will need to set up a local port forwarding. This can be done using the following command:

ssh -L local_port:localhost:remote_port user@remote_server

Replace "local_port" with a free port on your local machine (e.g. 3307), "remote_port" with the port on which your MySQL server is listening (e.g. 3306), "user" with your username on the remote server, and "remote_server" with the hostname or IP address of the server.

  1. After executing this command, your SSH client will create a tunnel between your local machine and the remote server.

  2. Now, open your MySQL client and connect to the database using the following connection details:

  • Hostname: localhost
  • Port: local_port
  • Username: your MySQL username
  • Password: your MySQL password

That's it! You should now be connected to your MySQL database via an SSH tunnel.

Note: Make sure that the local port you choose is not already in use by another application. Also, keep in mind that the SSH tunnel will stay active as long as the SSH connection is open. Once you close the SSH connection, the tunnel will be closed and you will no longer be able to connect to the MySQL server.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.