Forum Discussion
Connect to MySQL Database with Hostname via SSH Tunnel
Hi everyone,
I am facing the following issue: I would like to connect to a mysql database with a hostname using an SSH tunnel. The SSH tunnel is already configured using Putty. I have the server name, host name and port, database name, username, and password. Where do I enter information for the hostname and port number?
I've gone round and round in circles with this so any help would be appreciated!
The problem was with the database, there were additional firewalls that I could not get passed, even with the SSH tunnel.
To test the database connection over an SSH tunnel, follow these instructions (in local Windows):
- Open Command Prompt
- Enter the following prompts:
powershell
Test-NetConnection hostname -port xxxx
If the connection fails, Power BI will not be able to connect to the database.
6 Replies
- VahidDM
Super User
Hi vsorensen
Here are the steps to connect to a MySQL database with a hostname via an SSH tunnel:
-
Open Putty and establish an SSH connection to the remote server where the MySQL database is located.
-
In the Putty configuration window, go to Connection > SSH > Tunnels.
-
Enter the source port (e.g. 3306) under 'Source port' and the destination hostname and port (e.g. localhost:3306) under 'Destination'.
-
Click 'Add' and then 'Open' to establish the SSH tunnel.
-
Open a new command prompt or terminal window and enter the following command to connect to the MySQL database:
mysql -h localhost -u username -p
Replace 'username' with the MySQL username and enter the password when prompted.
-
If the connection is successful, you should now be able to access the MySQL database via the SSH tunnel.
Note: Make sure that the MySQL database allows remote connections from the SSH tunnel source IP address.
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
- vsorensenFrequent Visitor
Thank you for the instructions but I realize I need to clarify my question.
As I stated in my original post, I already have the SSH tunnel configured. To connect to the database, I use the following command in terminal:
mysql -h hostname --port = 1234 -u username -p
Once I enter my password, I can access the database no problem.
To connect to the database in Power BI, the server and database name are required fields. Since this database requires the host name and port number to gain access, how do I include the hostname and port in the connection options in Power BI?
- vsorensenFrequent Visitor
The problem was with the database, there were additional firewalls that I could not get passed, even with the SSH tunnel.
To test the database connection over an SSH tunnel, follow these instructions (in local Windows):
- Open Command Prompt
- Enter the following prompts:
powershell
Test-NetConnection hostname -port xxxx
If the connection fails, Power BI will not be able to connect to the database.
-