-1

I'm programming a C# program and I want to have access to a MySql database

I've found a few examples online. The format is:

"Server=ServerName;Database=databaseName;Uid=username;Pwd=password;"

I was wondering how will I be able to get the server name.

I installed mysql to localhost on my ubuntu server.

khelwood
  • 55,782
  • 14
  • 81
  • 108
Rain
  • 231
  • 3
  • 12

2 Answers2

1

ServerName is the IP of the Machine, in your case this will be localhost or 127.0.0.1 or the name of the Computer name(I don't know if there something like that in Ubuntu.

When researched it looks like you need command hostname. You can check this link

mybirthname
  • 17,949
  • 3
  • 31
  • 55
1

I'm guessing your C# code's running on Windows? If that's the case, you'll need to use the remote server's IP as the server name. Alternatively you can do start, run, cmd, nslookup server's ip - to translate the IP to a hostname, then use that as the server name.

NB: MySQL also needs to allow remote access. See How to allow remote connection to mysql for more info.

Community
  • 1
  • 1
JohnLBevan
  • 22,735
  • 13
  • 96
  • 178