问题
I have a database hosted with XAMPP on a PC with IP: 10.35.250.195
I want to access this database from a laptop in the same LAN where my C#-Application is running on. This is my connection-string:
"SERVER=10.35.250.195;DATABASE=testdb;USERID=root;PASSWORD=;"
But I'm being unable to open a connection from a remote pc/laptop.
I can access the database with the above connection-string from the PC where the database is hosted. I can also access the phpmyadmin in the browser from the remote laptop with "10.35.250.195/phpmyadmin". So the connection works from the laptop to the PC with the database, but I am not able to open this remote connection in C#.
Within phpmyadmin I allowed user "root" to access host 10.35.250.195 with all rights and I even allowed that every user can access host 10.35.250.195 with all rights to get sure (I know I should not do this because of security reasons...).
How can I access the database in c# with mysql from a remote PC via Lan? Can somebody help me to find the fault?
回答1:
Maybe your port of the DB is blocked by a firewall?
MySql has Port: 3306
and you could also try a PC based tool to test it like https://www.heidisql.com/
来源:https://stackoverflow.com/questions/46406777/c-sharp-remote-connection-to-xampp-database-via-lan