Setting up SSH key-based authentication and connecting to the server without typing a password is a fantastic idea. You will be logged in to the server and the SSH tunnel will be established after entering it. You'll be requested to enter your SSH user password after running the command.
-N - Instructs SSH not to execute a remote command.
You may construct an SSH tunnel with the following command if you're using Linux or macOS as your operating system: ssh -N -L 3336:127.0.0.1:3306 following are the options that are used: The ssh client is preinstalled on most Linux and Unix-based systems. SSH access to the system on which MySQL server runs.
We'll show you how to set up an SSH tunnel and connect to the MySQL server from a remote client in this tutorial. SSH tunneling is a means of relaying services ports through an encrypted SSH connection between a client and a server system. Configuring the MySQL server to allow remote connections is one approach, but this needs administration access and may pose security problems.Ĭreating an SSH tunnel from the local machine to the server is a more secure option. In other cases, though, you may need to connect to the server from a remote location.
The MySQL server by default only listens on localhost, which means it can only be accessed by programs running on the same machine.