user1447180
user1447180

Reputation: 13

How to Connect to Remote MySQL Server with my C# Application

I need to connect my C# application developed in my Standalone PC with my Hosted Linuux MySQL Server. How can i do it.. Is there any server configuration setup or any kind of Remote Connection Permission Setting have to be done? Please help with this..

Upvotes: 1

Views: 4195

Answers (4)

Muhamed Shafeeq
Muhamed Shafeeq

Reputation: 1214

Its Pretty Simple to Implement 1) Download My Sql Connector From https://dev.mysql.com/downloads/connector/net/6.9.html

2) In your C# Project add refrence of Mysql.Data.Dll

3) use this Connection String string connectionString= "SERVER=000.000.000.000;DATABASE=testdb;UID=test;PASSWORD=test123;" 4) use same like this sample code

MySqlConnection conn = new MySqlConnection(connectionString);
        try
        {
            Console.WriteLine("Connecting to MySQL...");
            conn.Open();
            // Perform database operations
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
        conn.Close();
        Console.WriteLine("Done.");

or Read this tutorials https://dev.mysql.com/doc/connector-net/en/connector-net-tutorials-connection.html

Upvotes: 0

user3363612
user3363612

Reputation: 1

Mysql has very good documentation how to connect mysql server (local and remote). It is here http://dev.mysql.com/doc/index-connectors.html And your case may be this http://dev.mysql.com/doc/connector-c/en/index.html

Upvotes: 0

Ramesh Rajendran
Ramesh Rajendran

Reputation: 38713

The connection string code should like this

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

You need to allow the remote connection by this way

Upvotes: 1

Andy Refuerzo
Andy Refuerzo

Reputation: 3332

Make sure that the server where MySQL is at can accept connections.

Read this to read how to configure your c# application to connect to MySQL.

Upvotes: 1

Related Questions