1

As I wrote in the topic, this works totally fine:

mysql_connect("server","username","password");

But this doesn't:

MySql.Data.MySqlClient.MySqlConnection connection =
   new MySql.Data.MySqlClient.MySqlConnection("SERVER=server;DATABASE=database;UID=username;PASSWORD=password;");
connection.Open();

The exception is always

Unable to connect to any of the specified MySQL hosts

And no, the question is neither a duplicate, nor answered there

5
  • Try replacing server with localhost Commented Feb 11, 2015 at 17:31
  • I already tried it, same exception... Commented Feb 11, 2015 at 17:31
  • check if database server is up. Commented Feb 11, 2015 at 17:33
  • connectionstrings.com/mysql - PASSWORD should be pwd. Better yet use MySqlConnectionStringBuilder so you don't have to worry about the details of the connection string, as per the answer in the question that I'm about to mark this a dupe of. Commented Feb 11, 2015 at 17:34
  • I just tried to connect with using the StringBuilder but the same error still appears... Commented Feb 11, 2015 at 17:42

1 Answer 1

1

As per the documentation, this

"SERVER=server;DATABASE=database;UID=username;PASSWORD=password;"

should be

"SERVER=server;DATABASE=database;UID=username;PWD=password;"
Sign up to request clarification or add additional context in comments.

1 Comment

I tried the string on another database server and it worked fine there...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.