Introduction
This article will cover connecting to MySQL using an SSH tunnel. This is significantly more secure than connecting directly to MySQL, as it does not require opening the MySQL port on the server and operates over a secure tunnel.
Connecting in MySQL Workbench
In MySQL Workbench, go to Database > Manage Connections.
Select New.
Change Connection Method to Standard TCP/IP over SSH.
Use the following settings:
SSH Hostname: The IP address of your server followed by :2223
SSH Username: Your SSH username.
SSH Password: We use SSH keys for authentication, so you do not need to enter a password.
SSH Key File: Enter the path to your SSH key file, or select the ... button to open your file browser to find and select the key file. Ensure you are using the private key and not the public (.pub) key.
MySQL Hostname: Use 127.0.0.1 unless you are in a clustered environment. If you are in a clustered environment, you can find the MySQL hostname in your site's configuration file.
MySQL Server Port: 3306
Username: Your MySQL username. This can be found in your site's configuration file.
Password: Your MySQL user's password. This can also be found in your site's configuration file.
An example configuration can be found below:
Select Test Connection to test the connection.
You can then connect to the database in Database > Connect to Database...
Connecting in other programs
Other programs such as Sequel Pro or DBeaver can be used as long as they support connecting over an SSH tunnel. They will use the same settings as described above, though the settings may be laid out differently in the interface.
Comments
0 comments
Article is closed for comments.