MySQL Forums
Forum List  »  Newbie

Re: connecting to Mysql server running on a different machine
Posted by: Sonic Sonic
Date: June 03, 2010 12:15PM

I have the same problem, can't connect anywhere except localhost.

And the problem is either with the connection string (I doubt it..), or the connector itself.

Because if I don't supply any server name or ip, it throws an exception, this is good. But no matter what dns / ip I set in connection string, it tries to connect to localhost, and fails because the username / password is different on my loaclhost then the remote server.

This is how i create connection string:
private string BuildConnectionString(string server, int port, string username, string password, string dbname)
{
MySqlConnectionStringBuilder msb = new MySqlConnectionStringBuilder();
msb.Server = server;
msb.Port = Convert.ToUInt32(port);
msb.UserID = username;
msb.Password = password;
msb.Database = dbname;
msb.CharacterSet = "utf8";
return msb.ToString();
}

It's working if it is the localhost, but nowhere else....
And I get an exception stating, that it can't connect username@localhost....
But I set the remote host to connect to......

And I'm out of ideas....

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.