I was looking for a workaround for configuring my database connection.
I saw that opening 3306 port is dangerous and we should be using SSH Tunnel instead to connect to the database.
I configured my MySQL server using docker and successfully connected it using MySQL Workbench
Now I have to configure and connect it to Visual Studio 2022 to be able to query to the database.
Visual Studio 2022 is only supported by MySQL Data thru NuGet packages which doesn’t have a gui connection setup.
I installed Visual Studio 2019 which is officially supported by MySQL Database and can be configured thru Data Source.
How can I setup MySQL Database connection to my Visual Studio if it’s SSH Tunnel configured.
Add Connection window only shows basic information about the connection. I’m not sure how to configure this over a SSH Tunnel.
Thank you in advance.
2
Answers
You can fill in the following information to configure the connection to the MySql database.
Server name: Enter the IP address of MySQL, which is 127.0.0.1 as seen in your SSL connection information.
User name: Enter the user name of Mysql
Password: Enter the password of Mysql
Database name: Enter a test database
Hope it can help you
For security reasons, sometimes the database server can only be accessed through SSH. For example, the MySql service is installed on server A, and machine A can only be accessed by machine B, and the deployment environment may be on machine C. In this case, C The server connects to the A server through the B server. At this time, SSH connection is required, and the SSH.NET class library is required:
code show as below:
Note: If an error occurs, you can stop the MySql service on the local (development machine).
Required dll: SSHDLL.rar