1

Good day; I am making an C# desktop application using MySQL as database. The execution works fine when using local server "localhost", but I want to install it in other computers and keep the database in my computer. I proceeded like following to allow other computers to connect the database :

  • I added a new user to the database and gave it all required permissions.
  • I added the IP address of the computer in which the database exist This is the connection string :
String connString = "Server = '192.168.xxx.xxx';  "
                     + "Port = '3306'; "
                     + "Database = 'mydb'; "
                     + "uid = 'dbUser'; "
                     + "pwd = 'userPassword';"
                     + "Persist Security Info=true;";

From the computer in which the database is installed, I can execute without any problem but from other computers I can not connect to the database. It gave me the error :

Unable to connect to any of the specified MySQL hosts.

  • Computers are in network but not in the same domain network.
  • There is no problem with the port.

Can anyone help me please ?

8
  • connectionstrings.com/mysql Commented Nov 26, 2022 at 9:54
  • BTW, I don't think Persist Security Info is applicable for MySQL. Commented Nov 26, 2022 at 9:55
  • Can you connect using MySQL Workbench or the like? That's how you determine the appropriate connection string. If you can connect from a management tool like that then programming languages in general are irrelevant to the issue. Commented Nov 26, 2022 at 10:44
  • the problem may be different domain networks or firewall blocking traffic. I suggest adding tags ip, internet, dns to the entry Commented Nov 26, 2022 at 12:25
  • You can check connection by telnet, or Test-NetConnection 192.168.xxx.xxx -Port 3306. Have you verified that MySQL Server is configured to accept remote connections? I'm not sure if in the case of different domains connected in a network, you don't need to configure something additionally - e.g. routing, unblocking ports. Maybe you could write how these domains are networked? how is routing set up? Is traffic on any port between machines working? Or maybe you need to refer to the name and configure internal DNS. Commented Nov 26, 2022 at 12:42

1 Answer 1

1

Finally, I resolved the problem. The problem was the port 3306 should be authorized by the firewall of the computer in which the database is installed. For those who got the same problem, this is the way how to resolve it :

  • Open firewall >> Advanced settings
  • Right click on Inbound Rules and choose the first option New Rule.
  • Check the second option Port, then click Next button
  • Be sure that TCP option is checked, then check Specific local ports and add the port 3306. Then Next and the port 3306 will be authorized and the connection from other computers permitted.
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.