1

I'm trying to connect to mysql database from C#, but I have no idea how to get the connecttion string, since ubuntu is not like mssql has a visual UI. I have install phpmyadmin on ubuntu server already

4
  • take a look here on how to connect to different types of databases hopefully this will help Connection Strings Commented Dec 2, 2014 at 14:40
  • connectionstrings.com/mysql Commented Dec 2, 2014 at 14:40
  • Thank You for your both answers Commented Dec 2, 2014 at 14:44
  • But I'm not sure about the Server=myServerAddress. Does it mean my IP? Commented Dec 2, 2014 at 14:45

1 Answer 1

1

it should looks like this

var str="Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword";

var connection = new MySqlConnection(str);

myServerAddress is the Ip of your server
Database is the name of your Databas
Uid is the username of the user that you want to use to authenticate to the database

Sign up to request clarification or add additional context in comments.

7 Comments

Thank you for your answer, But i'm not sure what should I put in the "Server=myserveraddress"
the ip of your server e.g. 172.12.7.xxx
@Rain it would be the server address, if its a local server this would be 127.0.0.1 or localhost. Otherwise its the IP of the host server.
One more question, when I was searching youtube video online, I see some people put in the port 3306 too, what is that for?
The port 3306 is the default MySql port, generally you should specify that, it depends on your server
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.