0

I have a C# application connecting to an external MYSQL database, all works fine but the company it is used on has MYSQL connections blocked and I cant have it allowed. I am rather new to C# and MYSQL and have researched HTTP and SSH tunneling but I don't see how to implement it into a C# program.

I need a way to get and send data to the MYSQL database around the firewall. Can someone please explain to me what my best option is and how to use it.

1
  • What OS are we talking about here? Linux or Windows?
    – Mark
    Aug 22, 2013 at 6:17

1 Answer 1

0

Microsoft Windows include a firewall which specifically blocks ports. If you plan on using MySQL through a network port then you should open and create an exception for this port before performing the installation. To check and if necessary add an exception to the firewall settings:

First ensure that you are logged in as an Administrator or a user with Administrator privileges.

  1. Go to the Control Panel, and double click the Windows Firewall icon.
  2. Choose the Allow a program through Windows Firewall option and click the Add port button.
  3. Enter MySQL into the Name text box and 3306 (or the port of your choice) into the Port number text box.
  4. Also ensure that the TCP protocol radio button is selected.
  5. If you wish, you can also limit access to the MySQL server by choosing the Change scope button.
  6. Confirm your choices by clicking the OK button.

Additionally, when running the MySQL Installation Wizard on Windows 7 or newer, ensure that you are logged in as a user with administrative rights.

When using Windows Vista or newer, you may want to disable User Account Control (UAC) before performing the installation. If you do not do so, then MySQL may be identified as a security risk, which will mean that you need to enable MySQL. You can disable the security checking by following these instructions:

Try to Open Control Panel.

  1. Under the User Accounts and Family Safety, select Add or remove user accounts.
  2. Click the Got to the main User Accounts page link.
  3. Click on Turn User Account Control on or off. You may be prompted to provide permission to change this setting. Click Continue.
  4. Deselect or uncheck the check box next to Use User Account Control (UAC) to help protect your computer. Click OK to save the setting.

You will need to restart to complete the process. Click Restart Now to reboot the machine and apply the changes. You can then follow the instructions below for installing Windows.

Connecting to MySQL Remotely from Windows with SSH

This section describes how to get a secure connection to a remote MySQL server with SSH. The information was provided by David Carlson .

  1. Install an SSH client on your Windows machine. As a user, the best nonfree one I have found is from SecureCRT from http://www.vandyke.com/. Another option is f-secure from http://www.f-secure.com/. You can also find some free ones on Google at http://directory.google.com/Top/Computers/Internet/Protocols/SSH/Clients/Windows/.
  2. Start your Windows SSH client. Set Host_Name = yourmysqlserver_URL_or_IP. Set userid=your_userid to log in to your server. This userid value might not be the same as the user name of your MySQL account.
  3. Set up port forwarding. Either do a remote forward (Set local_port: 3306, remote_host: yourmysqlservername_or_ip, remote_port: 3306 ) or a local forward (Set port: 3306, host: localhost, remote port: 3306).
  4. Save everything, otherwise you will have to redo it the next time.
  5. Log in to your server with the SSH session you just created.
  6. On your Windows machine, start some ODBC application (such as Access).
  7. Create a new file in Windows and link to MySQL using the ODBC driver the same way you normally do, except type in localhost for the MySQL host server, not yourmysqlservername.

At this point, you should have an ODBC connection to MySQL, encrypted using SSH.

References:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.