连接到LAN上的远程数据库(mySQL) [英] Connecting to a Remote Database(mySQL) on LAN
问题描述
我以前在同一台PC上连接过VB.net和mySQL,但是我不知道如何将VB.net连接到远程PC(LAN)
我只更改了服务器
这是我的代码.我删除了一些细节,但它在server = localhost
上有效
(切换纯文本)
conn = New MySqlConnection()
conn.ConnectionString =服务器= 192.168.1.4;" & _
用户ID =根;" & _
密码=;" & _
数据库=系统"
试试
conn.Open()
MsgBox(您有控制权")
conn.Close()
异常捕获
MsgBox(连接失败")
结束尝试
我已从两侧关闭防火墙,并且一直返回连接失败"
I have connected VB.net and mySQL on a the same PC before, but I have no Idea how to connect VB.net to a remote PC(LAN)
I''ve only changed the server
This is my code. I removed some of the details, but it works on server=localhost
(Toggle Plain Text)
conn = New MySqlConnection()
conn.ConnectionString = "server=192.168.1.4;" & _
"user id=root;" & _
"password=;" & _
"database=system"
Try
conn.Open()
MsgBox("You have control")
conn.Close()
Catch ex As Exception
MsgBox("Connection Failed")
End Try
I have turned off firewalls from both sides, and it keeps returning "Connection Failed"
推荐答案
将MySQL安装配置为允许TCP/IP连接, ^ ].
尝试使用可用的管理工具之一 [连接字符串 [
Was the MySQL installation configured to allow TCP/IP connections, this is a good example for installing MySQL on a Windows system[^].
Try one of the admin tools that are available[^] and see if it can connect to your remote server.
If MySQL is configured correctly the next thing is your connection string[^] which one you use is dependent on which MySqlConnection you are using.
Some connection string exmaples are:
The standard MySQL supplied connection it should be;
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
If you are using the one created by the MySQLDriverCS project team it would be;
Location=myServerAddress;Data Source=myDataBase;User ID=myUsername;Password=myPassword;Port=3306;Extended Properties="""";
这篇关于连接到LAN上的远程数据库(mySQL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!