Nexcess Logo

How to Create an SSH Tunnel for a MySQL Database

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
March 24, 2022


Secure Shell (SSH)-Tunneling provides strong authentication and secure encrypted communication between two hosts and lets you manage the databases remotely.

Creating an SSH Tunnel for Your Site’s MySQL Database

Why SSH-Tunneling with the MySQL Port?

By default, your databases are not directly accessible from outside the Nexcess environment since the database cannot reliably maintain the security and patch levels available with the Secure Shell Protocol (SSH). This is where the MySQL SSH Tunnel comes in handy.

Secure Shell or SSH is a client-server-based communication protocol that is used to securely to connect from one machine to another. For example, SSH-Tunneling with the MySQL Port (Port 3306) forwarding provides strong authentication and secure encrypted communication between two hosts and lets you manage the databases remotely.

The most popular software tools used to connect to a MySQL database through tunnels are MySQL Workbench and Navicat for MySQLBoth of them let you manage your databases remotely without having to go through logging into the Nexcess Portal every time you want to make database changes.

How to Connect to a Database Through a MySQL SSH Tunnel

Prerequisites to Connect to a Database Through a MySQL SSH Tunnel

You can easily find this information using the Nexcess Portal Dashboard.

How to Connect to a Database Through a MySQL SSH Tunnel Using the MySQL WorkBench Client

You can download MySQL Workbench client from here: 

MySQL Community Downloads > MySQL Workbench

Once downloaded and installed, please follow the below steps to create an SSH tunnel for MySQL using MySQL WorkBench.

Using the MySQL WorkBench Client Steps 1-7

  1. Open the MySQL Workbench client and click the Plus Icon to the right of MySQL Connections test string as shown in the image below:

MySQL Workbench

  1. Fill in the connection parameters as listed below:

  • Connection Name: The connection name for your reference.
  • Connection Method: Choose Standard TCP/IP over SSH from dropdown menu.
  • SSH Hostname: Provide the Nexcess IP / Hostname. (Note: No need to supply the optional port, as the default SSH port is 22.)
  • SSH Username: The SSH Username.
  • SSH Password or SSH Key File: The SSH Password or SSH Key File is used to connect the remote system over SSH.
  • MySQL Hostname: Leave it as '127.0.0.1' to access the MySQL server installed on the same remote system.
  • MySQL Server Port: 3306
  • Username: The MySQL Database Username to be used to open the connection.
  • Password: The MySQL Database User Password to be used to open the connection. You have the option to store it in the vault by clicking the Store in Keychain button.

connection parameters

  1. Click the Test Connection button after filling in all the fields. It might show the Connection Warning message when the connection is used for the first time as shown in then image below. Click on the Continue Anyway button when the prompt appears:


Connection Warning


  1. Click the OK button to confirm the connection. It will prompt for the password if you have not stored it previously in the vault.


  1. Provide the password and click the OK button. As shown in the image below, it will render the ‘Successfully made the MySQL connection’ message.

‘Successfully made the MySQL connection

  1. Now click the OK button to close the dialog box. Also, click the OK button to add the connection to the Connections Library.


  1. Now click on the newly added connection to connect to the MySQL Server. It will create an SSH Tunnel for MySQL. 


SSH Tunnel for MySQL


List the databases by clicking the Schemas Tab as shown in image below.

Schemas Tab

How to Connect to a Database Through a MySQL SSH Tunnel Using the Navicat for MySQL Client

You can download the Navicat for MySQL client from here:

Navicat for MySQL 


Once downloaded and installed, please follow the below steps to create an SSH Tunnel for MySQL using Navicat for MySQL.


Using the MySQL Navicat for MySQL Client Steps 1-6


  1. Open your Navicat for MySQL client and click Connection > MySQL option from dropdown menu:


Connection > MySQL


2. In the General Tab section, fill out the fields as follow:

  • Connection Name: The connection name for your reference.
  • Host: localhost
  • Port: 3306
  • User Name: The MySQL Database Username to open the connection.
  • Password: The MySQL Database User Password


General Tab

3. Then, go to the SSH Tab section, check the Use MySQL SSH Tunnel checkbox and fill out the fields as follow:

  • Host Name/IP Address: Provide the Nexcess IP / Hostname.
  • Port: 22
  • User Name: SSH Username
  • Authentication Method: Password
  • Password: SSH Password




4. Click the Test Connection button on the New Connection dialog box shown above after completing all the fields. It will show the ‘Connection Successful’ message as shown in image below:


Connection Successful


5. Click the OK button to close the dialog box. Again, press OK to save the connection settings. You should see your new connection on the left in the panel listing connections:

new connection


6. Double-click on the connection name to connect to your database. It will connect to MySQL through an SSH Tunnel. List the databases by clicking the Schemas navigational elements as shown in the image below:


databases


Common Issues

Below are some of the issues faced on trying to create an SSH Tunnel for MySQL.

Common Issue #1: Temporary Block of Your IP Address

If you try to connect to the MySQL SSH Tunnel using wrong credentials/settings, your IP address will get temporarily blocked. If you do face any such issue, please note those blocks cannot be lifted, and you can retry connecting to the same MySQL SSH Tunnel after some time.

Common Issue #2: Recurring Timeouts While Connecting

              

A timeout is one of the most common issues faced while using desktops clients when connecting to MySQL through an SSH Tunnel If you do encounter any timeout issues, please try updating the SSH preferences on the MySQL client. 

Common Issue #3: Database User Lacking Proper Permissions 

    

Ensure the database user has proper permissions over the database you are trying to connect. You can check and update the permissions within the Nexcess Portal.


Useful WordPress Links for Developers & Admins

Consider Hosting with Nexcess

Hosting optimized for the industry's leading platforms, including Managed WordPress Hosting, Managed WooCommerce Hosting, and Managed Magento Hosting:

Build Better Sites and Stores With Fully Managed Hosting from Nexcess 

Faster Speeds, Stronger Security, Inherent Scalability and Trusted Support.

Our range of hosting plans caters to any business scale. We do all the heavy lifting for you to focus on growing your business. In addition, we automatically update ore components and plugins to the latest version and ensure your hosting environment is properly optimized, secured, and updated.


Nexcess infrastructure was specially designed to keep up the best speed and performance in the industry. No traffic surge can threaten your website to go down thanks to our autoscaling technology which adds more resources to your server to handle the load. In addition, we offer always-on security monitoring and support from web hosting experts 24/7/365 and a built-in CDN with 22 locations and advanced caching for ultra-fast loading.


All hosting plans include The Nexcess 30-Day Web Hosting Money Back Guarantee.

Why Choose Nexcess?

Because we're different! Chris Lema captures "the why" in his passionate and stirring recount of a Nexcess support-related story.




Useful YouTube > Nexcess Channel Links

Resources for More Information

Need more help? The Applications, WooCommerceand WordPress sections within the Nexcess Knowledge Base are important resources for those seeking additional knowledge. 

The Applications section also contains valuable insights for those seeking additional knowledge about our other various hosted applications and platforms. Check out our related video playlists and articles below:


Need a No-Code Website Building Solution? 


Are you on an accelerated schedule and already ready to move forward? If you need to get started with your Nexcess StoreBuilder Solution sooner rather than later, check out these resources:


Next Steps with a Nexcess Cloud Hosting Solution?

Read more about the Fully Managed Cloud Environment by Nexcess and its benefits for your business.

A Cloud Hosting Solution That Lets You Do Business Your Way 

We believe in the promise of cloud: scalability, security, performance, and ease of use. Together with our team, clients, and partners, we’ve built something better.

Choose From Multiple Applications 

Whether you’re a small business or a high-traffic eCommerce store, our cloud hosting solutions are designed around your needs: auto scaling, PCI compliance, and comprehensive development tools provide you with maximum dynamic flexibility in a fully managed cloud environment.


We make applications easy with environment optimizations for:


And there are many more!


We also have a variety of Nexcess support articles about how best to implement our product offerings housed in the Nexcess Knowledge Baseincluding how to get your site going with a number of different configuration options. These resources include a great article on setting this up for Migrating to Nexcess with managed WordPress and managed WooCommerce hosting

24-Hour Assistance

If you need any assistance with the above-mentioned, don't hesitate to reach out. For 24-hour assistance any day of the year, Nexcess customers can contact our support team by email or through your Client Portal.

New Customers: Fully Managed Hosting Solutions


Not a Nexcess customer yet? Check out our fully managed hosting solutions. The option to chat with an expert is also available.

Related Articles


Rajil Rajan
We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.