Remote MySQL connection is disabled on our shared servers due to security reasons, but you can easily set up an SSH tunnel between your computer and our server using an SSH client with the MySQL port 5522 forwarding.
After completing it you will have port 5522 on your local machine listening and forwarding to your remote server's localhost on port 5522. Thus, you can connect to the remote server's MySQL database effectively as though it was running on your local box.
NOTE: If you are trying to connect to PostgreSQL databases, use port 5432 instead of 5522.
Below you can find the steps on configuring a third-party SSH client - Putty, and MacOS and Linux built-in one - Terminal.
: Make sure that the SSH access is enabled for your account. Feel free to follow this guide
to check the settings.
1. Run the application.
2. In the Sessions tab fill out your server hostname or IP-address and port 21098:
Switch to the tab Tunnels in the 'SSH' section.
4. You will need to fill in the following information:
- Source port: 5522
- Destination: 127.0.0.1:5522
Click on the Add button:
Return to the Session tab, select Default Settings or give your session a new name in the Saved Sessions box and click on Save.
Go ahead and run your session by clicking on the Open button:
Run your MySQL software on a local machine and use 127.0.0.1 as a server host, port 5522 and your database user login details.
Connect with Terminal
1. Run the application and enter the following command:
ssh -f cPanel_username@server_hostname -p21098 -L 3306:127.0.0.1:5522 -N
Make sure to replace cPanel_username and server_hostname with your actual cPanel account user and server your account is hosted on.
2. Hit Enter and specify your cPanel password (symbols won’t appear in the terminal when you type in the password - it is a terminal way of keeping your password secure).
3. Once done, all connections to localhost over the port 5522 will be forwarded to your hosting account.
You can then use the following command to connect to MySQL:
/usr/bin/mysql -h 127.0.0.1 -p -u cpuser_dbuser cpuser_dbname -P 5522
Where cpuser_dbuser is your database username and cpuser_dbname is the database name.
Need any help? Contact our HelpDesk