C#-通过LAN远程连接到XAMPP数据库 [英] C# - Remote Connection to XAMPP-Database via LAN
问题描述
我有一个IP地址为10.35.250.195的PC上的XAMPP托管数据库
I have a database hosted with XAMPP on a PC with IP: 10.35.250.195
我想从运行C#-Application的同一LAN中的笔记本电脑访问此数据库. 这是我的连接字符串:
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=;"
但是我无法从远程PC/笔记本电脑打开连接.
But I'm being unable to open a connection from a remote pc/laptop.
我可以从托管数据库的PC上使用上述连接字符串访问数据库.我还可以使用"10.35.250.195/phpmyadmin"从远程笔记本电脑在浏览器中访问phpmyadmin.因此,从笔记本电脑到具有数据库的PC的连接都可以正常工作,但是我无法在C#中打开此远程连接.
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#.
在phpmyadmin内,我允许用户"root"以所有权限访问主机10.35.250.195,甚至允许每个用户以所有权限访问主机10.35.250.195以确保安全(我知道出于安全原因我不应该这样做)原因...).
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...).
如何通过Lan从远程PC用mysql在c#中访问数据库?有人可以帮我找到问题吗?
How can I access the database in c# with mysql from a remote PC via Lan? Can somebody help me to find the fault?
推荐答案
也许您的数据库端口已被防火墙阻止?
Maybe your port of the DB is blocked by a firewall?
MySql的端口号:3306
MySql has Port: 3306
,您还可以尝试使用基于PC的工具进行测试,例如 https://www.heidisql.com/
and you could also try a PC based tool to test it like https://www.heidisql.com/
这篇关于C#-通过LAN远程连接到XAMPP数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!