Example :
How to set up an email or change my account settings.
- Help Center
- Web Hosting
- Database: mySQL
- How to Establish Remote MySQL Access on Our Hosting
How to Establish Remote MySQL Access on Our Hosting
To minimize server vulnerabilities, closing port 3306 is a precautionary measure to limit access to important services on the server. This is why MySQL port 3306 has been restricted; blocking all traffic to MySQL port 3306, except from the server’s own IP, is a good security measure.
The default MySQL port is 3306, but this doesn’t necessarily mean the MySQL service will always use this port. If you need to connect to your database remotely, there are more secure options than simply opening port 3306, such as using an SSH tunnel.
After configuring the SSH tunnel, port 23306 on your local machine will listen and forward traffic to your remote server’s localhost on port 3306 via an SSH client (such as PuTTY) with MySQL port 3306 forwarding enabled. This setup allows you to connect to the remote server’s MySQL database as if it were running locally on your machine.
What you need to set-up SSH Tunnel:
1. SSH Client (PuTTy for windows user, Terminal for Linux and macOS user)
2. SSH Username and Password details from your cPanel server
3. Server-side MySQL Database details
4. Tunnel details
5. Client-side MySQL Database details
Note: SSH access is enabled on customer account on Port 9022 by default.
Step on how to configure a third-party SSH client (PuTTY on Windows PC) and built-in (Terminal) on macOS and Linux.
1. Download SSH Client (Search for Putty official download page).
2. SSH Username and Password details from your cPanel server.
• Server hostname: 163.44.242.15
• Port: 9022
• cPanel username: fzsfqvsq
• cPanel password: cpanel_password
Server hostnames are uniquely assigned, you will have different for your account.
Your cPanel username and password are what you use to log in to your cPanel account.
Our Shared Hosting servers uses port 9022 on SSH connection.
To locate your IP address or Server Hostname:
Login to your cPanel and find the IP at Tools > Under General Information > Shared IP Address.
In the above screenshot, the IP 163.44.242.15 is your Server hostname for establishing SSH sessions.
3. Server-side MySQL Database details.
• Server hostname: 127.0.0.1
• Port: 3306
• Database name: fzsfqvsq_mydb
• Database user: fzsfqvsq_mydbuser
• Database password: db_password
On your cPanel create your database at Tools > Database > Manage My Databases.
Please replace above detail with your own Database information.
4. Tunnel details.
• Local IP: 127.0.0.1
• Local Port: 23306
• Remote IP: 127.0.0.1
• Remote Port: 3306
Local IP address and Port can be modified depending on your preference.
On this example we will use Port 23306 since customers are utilizing the default MySQL port 3306. Confirm and make sure that specified local port is not used by any service.
Further, double checked that your remote IP address and Port should match the server hostname and port from Server-side MySQL details and please note that these are unchangeable.
5. Client-side MySQL Database details.
• Server hostname: 127.0.0.1
• Port: 23306
• Database name: fzsfqvsq_mydb
• Database user: fzsfqvsq_mydbuser
• Database password: db_password
Client-side MySQL access details are what you need at your app or website user end to connect to the database remotely. Your server hostname and port should match Local IP and Port from the Tunnel configuration details.
Confirm your database credentials, username and password should match corresponding information from Server-side MySQL details.
■ Connect with PuTTY
1. Go to the Connection > Click Data, on Log-in details area on the right side:
Confirm that the Auto-login username field is empty (or key in your cPanel username if you like), Select Prompt option.
2. Still at Connection tab > Click SSH > Tunnels tab, on Add forwarded port area. Enter your Tunnel details please see (#4) above for details:
Source Port = Local Port
Destination = RemoteIP:RemotePort
Make sure that the Local and Auto mode are selected then click Add. The newly added port will be listed under Forwarded ports area.
3. Move on Session tab and fill in the Host Name (or IP address) and SSH Port using the SSH connection details (please see #2 for details).
Next on the Saved Sessions field enter your SSH tunnel preferred Name then click Save button to save the configuration. This for identification and convenience on future connection use.
4. Click Open to establish a connection to the server.
5. Connecting to the server for the first time, you will be prompted with security warning. Click on Accept button to procced.
6. To proceed with the connection, enter your cPanel username and password.
You will now be prompted to [Login as:] enter your cPanel username.
Enter your password found in your SSH connection details.
Note: When you enter your cPanel password, no cursor or symbols will appear. This is for security. Just type your password and press enter when finished.
The server will prompt once you are successfully connected.
The SSH tunnel has been established, and any connections made to localhost on port 23306 will now be forwarded to your hosting account.
Note: The SSH tunnel will stay active until you close this PuTTY window. Keep it open while you work on your database.
You can now connect to a database on the Shared Hosting server using the Client-side MySQL details with your preferred MySQL client. Please see example below.
■ Connect with Terminal (for Linux and macOS)
1. On your Mac or Linux PC, open and run the terminal application and enter the following command, then hit Enter in your keyboard:
ssh -f fzsfqvsq@163.44.242.15 -p9022 -L 23306:127.0.0.1:3306 -N
Where:
” fzsfqvsq@163.44.242.15 -p9022 ” is your SSH connection details.
[cPanel_user_account]@[server host IP] -p[port]
“-L 23306:127.0.0.1:3306” is your Tunnel Details:
[Local Port]:[Remote IP]:[Remote Port]
The local IP address, which is not specified, defaults to 127.0.0.1.
2. Enter your cPanel password.
When you enter your cPanel password, no cursor or symbols will appear. This is for security. Just type your password and press enter when finished.
When connecting to the server for the first time, you will see a security warning. Type Yes and press Enter to continue.
3. All connections to localhost over the port 23306 will be forwarded to your hosting account once you’ve done. You can now connect to a database on the Shared Hosting server using the Client-side MySQL details with any MySQL client.
Let’s set up an example using a command-line MySQL client:
mysql -h 127.0.0.1 -P 23306 fzsfqvsq_mydb -p -u fzsfqvsq_mydbuser
It will look like as below: