Remote connection to the MySQL database through a secure SSH tunnel
Advantages of the solution
Since the remote connection to the MySQL database used by the Remote MySQL Database function in cPanel is unencrypted by default, we recommend using an SSH tunnel. Thanks to this, we will connect to the base inside the secure encrypted SSH transmission.
There is also no need to enter our IP in cPanel, as before in the "Remote MySQL database" solution.
What will you need?
In order for us to be able to connect to our account via SSH, we will need to enable SSH access for our account via the Subscriber Panel:
https://www.smarthost.eu/panel/
We expand the details of the hosting account with the magnifying glass icon and then click the Enable SSH button.
Remember to create a database earlier, a database user and assign this user to the database, giving him the appropriate permissions. We do all this through cPanel. More information can be found in the guide:
https://www.smarthost.pl/jak-zalozyc-nowa-baze-danych-mysql/poradniki
Tutorial for Windows using PuTTY
We will use PuTTY to create the tunnel - it is free and you can download it from the website:
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
We install and run the program.
In the first field we enter our cPanel login, then @, then the name of our Smarthost account. In the second field, we enter port 5739.
From the menu on the left, expand SSH by clicking the square with +. Additional options are developing from which we select Tunnels. Enter the values as in the picture below, select IPv4 and click Add. At the end, we click Open (we can also go to the initial Session screen and save our settings).
A console window will appear, asking us to enter a password - we enter a password such as for cPanel. We don't close this window until we connect to the base.
To connect to the database now, it is enough to enter the host address on our computer: localhost and standard MySQL port: 3306
The second way is to use the command line where we enter the command:
ssh -L 3306: localhost: 3306 login@client-name.smarthost.pl -p 5739
Guide for Linux and macOS, using the ssh command
We enter the command:
ssh -L 3306: localhost: 3306 login@client-name.smarthost.pl -p 5739
where instead of login we give our cPanel login, and instead of customer-domain.eu we give our main domain of the account.
We will be asked for the password, after entering it, the tunnel will be active until we close the connection with the exit command.
To connect to the database now, it is enough to enter the host address on our computer: localhost and the standard MySQL port: 3306
Speed and performance: full SSD, http/2, multiple cache methods, free data migration, free SSL certificates
Security and performance: full separation, anti-exploit technology, full SSD, http/2, free SSL certificates
Several hundred types of domains from all around the world can be registered at Smarthost.au. Our prices are affordable for everyone.