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 use 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
mysqlcommands 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:
instance through it.
for connections from your desktop machine’s IP address.
Option one is more secure.