[英]How to connect remotely to MySQL server
What is the best way to connect remotely to MySQL
server on domain ? 在域上远程连接到
MySQL
服务器的最佳方法是什么?
I want to make an desktop app or maybe it is easier to do it with asp.net
? 我想制作一个桌面应用程序,还是用
asp.net
做起来更容易?
Use Mysql Workbench for desktop use to connect to Mysql Server. 使用Mysql Workbench供桌面使用以连接到Mysql Server。
For coding: Get Mysql client library for .net . 对于编码:获取.net的Mysql客户端库。 It's called mysql connector.
它称为mysql连接器。 Add
加
using Mysql.Data; 使用Mysql.Data; namespace
命名空间
https://dev.mysql.com/doc/connector-net/en/connector-net-programming-connecting-open.html https://dev.mysql.com/doc/connector-net/zh/connector-net-programming-connecting-open.html
your code will look very similar like this one: 您的代码将看起来像这样:
MySql.Data.MySqlClient.MySqlConnection conn;
string myConnectionString;
myConnectionString = "server=127.0.0.1;uid=root;" +
"pwd=12345;database=test;";
try
{
conn = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);
conn.Open();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
MessageBox.Show(ex.Message);
}
1- I usually use HeidiSQL tool to connect to MYSQL server otherwise on localhost or remotely servers on CPanels. 1-我通常使用HeidiSQL工具连接到MYSQL服务器,否则连接到localhost或CPanels上的远程服务器。
most of CPanels allow to remote connection by adding % at access hosts field to enable me connect remotely anywhere. 大多数CPanels通过在“访问主机”字段中添加%来允许远程连接,使我可以在任何地方远程连接。
from your cpanel go to the database tools then -> you will find link for Remote mysql -> then you can any IP address to make server allow to connect, if you want connect anywhere you put %. 从cpanel转到数据库工具,然后->您将找到Remote mysql的链接->然后,您可以使用任何IP地址使服务器允许连接,如果您想在%放置的任何地方进行连接。
Note: CPanels are little different each others. 注意:CPanels彼此之间几乎没有什么不同。
2- if you want connect to mysql in your code, you make a normal connection after doing step 1. 2-如果要在代码中连接到mysql,请在执行步骤1之后进行正常连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.