0

With the service running on my machine(Setup on a LAN with no internet connection), I can connect with the following :

string sConnection = @"Server=localhost; Port=3306; Database=some_database; Uid=root; Pwd=genericpassword;";

MySqlConnection cnTest = new MySqlConnection(sConnection);

cnTest.Open();

How should I Modify my connection string to connect from another PC on the lan to my MYSQL server? *side note : The IP of my local machine is setup to be 192.168.0.1.

1

1 Answer 1

1

What goes after "Server=" is the address of the server.

So if your server is on 192.168.0.1 - it'll look like

string sConnection = @"Server=192.168.0.1; Port=3306; Database=some_database; Uid=root; Pwd=genericpassword;";

Just replace 'localhost' with the address you're given.

That said, it's generally considered to be good procedure to store connection strings in web.config / app.config - whenever you deploy it on some other environment, you won't want to rebuild it. This link might help with that.

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

Comments

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.