3

I work in C # through MySQL.Data.dll. Normally, all works fine, but sometimes it pops up an error "Unable to connect to any of the specified MySQL hosts". What is this error and how to get rid of it?

Mediator
  • 14,951
  • 35
  • 113
  • 191

3 Answers3

6

You may check mysql server is working or not and you can add port number of mysql in connection string like this

    "Server = myServerAddress;
       Port = 1234;
   Database = myDataBase;
        Uid = myUsername;
        Pwd = myPassword;"
Bhushan Firake
  • 9,338
  • 5
  • 44
  • 79
Thiru G
  • 620
  • 2
  • 6
  • 17
  • 3306 is the default MySQL port number. We can set a port number when install the mysql. – Thiru G Jan 12 '11 at 07:12
  • some connection string variables here: Server; Database; Uid; Pwd; default command timeou; port; Connection Timeout; Protocol; Encryption; and some more. – Thiru G Jan 12 '11 at 07:17
0

I was having a having a hard time connecting to a MySQL database on HostGator through port while debugging locally. What worked for me was to change the trust level in my local web.config from medium to full.

<system.web>
    <trust level="Full" />
</system.web>
Southern Fire
  • 151
  • 1
  • 3
0

Can you connect to the MySql Host through MySql Workbench?

Using the same connection parameters in your application do you get the same error?

Have you setup the user account, access, schema and roles as required?

The standard port used for connections is 3306, you can change this via the configuration settings, on a local pc look for the 'my.ini' file in the root installation directory.

Lloyd
  • 2,932
  • 2
  • 22
  • 18