Turning Putty Login Credentials Into C# MySqlConnection Connection String
I'm having a bit of trouble connecting to my SQL database through my C# code. I can connect to it fine using Putty and the server I am connecting to is based in Germany, I am here in the UK.
When I use Putty I use these credentials:
Host Name:
sample-intra.net
Port:
2223
And then to login using the window that opens I type
login as: my_username
password: my_password
then once access has been granted I type:
mysql -h localhost -u root -p
and then when asked for the password I enter
my_password
once again.
That works fine and I can access my database (called SampleDB
) fine, and access all the tables, but I am having trouble turning this in to a C# connection string I can u开发者_如何学Pythonse with the SqlConnection
object. If someone can provide me with the connection string based on the above credentials I would appreciate it greatly.
Many thanks
Because you're first connecting with PuTTY to SSH into your server, and then running mysql
commands while connected, it's as if you're physically sitting at the console of the server. In other words, you connected to your mysql instance using the address "localhost" because you are indeed already on that machine.
There's two things you could do here to work around your problem:
- Make an SSH tunnel in PuTTY, and connect to your MySQL instance through it.
- Enable remote access in your MySQL server for connections from your desktop machine's IP address.
Option one is more secure.
精彩评论