?
Solved

Accessing a remote MySQL database over SSH in .NET???

Posted on 2007-08-08
5
Medium Priority
?
485 Views
Last Modified: 2013-11-05
Hi,

I am trying to access a remote MySQL database in ASP.NET. Normally, to access the database, i manually SSH to the server and then login to MySQL. However, i am not sure how to do that through code.

It would be nice if i could just create a connection string like:

 Dim myConnectionString As String = _
                            "server=192.168.xx.xxxx;" & _
                            "Database=TestDB;" & _
                            "User ID=username1;" & _
                            "pwd=xxx;"

But that won't work because i haven't first created an SSH connection. Is there a way to create an SSH connection in .NET before connecting to a remote database?.

Thanks,

Jon
0
Comment
Question by:Allston44
  • 2
  • 2
5 Comments
 
LVL 51

Expert Comment

by:Steve Bink
ID: 19658570
You should not need to create an SSH connection.  SSH stands for "secure shell", and is a method to gain remote command line access.  Your server should be running mysql on port 3306, which means you can hit it directly instead of shelling in and using the command line.

Here's one code example of how it is done:

http://www.aspdev.org/articles/asp-mysql-connect/
0
 
LVL 17

Expert Comment

by:Aleksandar Bradarić
ID: 19660157
Did you mean SSL connection? If yes, then you are right, there is a way to access MySQL securely by using a SSH tunneling component.

Some sample links:
  http://www.topshareware.com/SSH-Tunnel-Client-download-18466.htm
  http://www.topshareware.com/Internet-Secure-Tunneling-download-10168.htm
  http://www.weonlydo.com/index.asp?showform=SSHTunnel
0
 

Author Comment

by:Allston44
ID: 19662787
thanks routinet, in general i have no trouble connecting to al MySQL database. The trouble has been connecting to this database remotely (even when using the method you described above). For whatever reason, i can only connect to it when i go through SSH (i didn't realize it was just for command line) Could it be that the hosting service is blocking remote access to port 3306?

leannonn, one of those products looks promising, but i'd prefer to avoid paying for a compononet. I will reconsider as a last option...


Thanks.



0
 
LVL 17

Expert Comment

by:Aleksandar Bradarić
ID: 19664038
> Could it be that the hosting service is blocking remote access to port 3306?

Yes, definitely. Many of them close the port from `security reasons`, as they say :(
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 1400 total points
ID: 19666746
> Could it be that the hosting service is blocking remote access to port 3306?

As leannonn indicated, some hosts close all ports, and open only the ones you request.   You should check with them to make sure this is not an issue.

Another common problem is not adding the correct user@host information into MySQL.  Have you verified that the ASP server's information has been given the proper permissions to access the db?  Check here for more info:

http://dev.mysql.com/doc/refman/5.0/en/account-management-sql.html
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question