1
Reply

How to connect to a remote MySQL server using C#?

Jim Tat

Jim Tat

Oct 27 2016 10:36 AM
363
I have a C# Application which would access a MySQL server using WAMP on another computer. I am trying to do it via IP. Here is my Connection String :
  1. server = "192.168.10.221";  
  2. database = "restaurantdb";  
  3. uid = "root";  
  4. password = "";  
  5. string connectionString;  
  6. connectionString = "SERVER=" + server + "; PORT = 3306 ;" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";  
  7. mycon = new MySqlConnection(connectionString); 
 I have another computer in which we are in the same network, but when I try to connect to the Mysql I am not able to connect but locally it works...
What do you think ?

What I have tried:

I published my C# application and then launch it in the other computer so that I will try to connect to mysql but nothing works. But I have to mention that when I put the ip adress in the other computer I can have access to wampserver and phpmyadmin ...
I got this error: .MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
 

Answers (1)