简体   繁体   中英

Cannot connect to MySQL on local server

I have recently installed MySQL on our local server, and I am attempting to connect to it using this connection string:

mySqlConnectionString = "server=192.168.1.254;database=dcim;uid=root;pwd=LlmD62jL;";

I have also tried adding the port as well:

mySqlConnectionString = "server=192.168.1.254:3306;database=dcim;uid=root;pwd=LlmD62jL;";

But I still keep getting the MySqlException:

1042 - Unable to connect to any of the specified MySQL Hosts.

I have tried with the Firewall active and de-activated, but nothing has worked so far. What's going on?

EDIT: I thought I should note that I used this connection string to connect to MySQL on the same machine, with no problems using localhost or 127.0.0.1 .

NB: This is MySQL Server with .NET Framework connection.

  1. First check mysql server is working or not .
  2. Try to add port number of mysql in connection string(The port 3306 is the default MySql port).
  3. Check spacing and Order of parameters in connection string.(Sometimes it matters base on my experience",) )

Here's the basic format you could follow:

Server=ServerAddress; Port=1234; Database=DataBase; Uid=Username; Pwd=Password;

Also try to read this article its useful for connection strings. MySQL connection strings

Hope it helps. ",)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM