简体   繁体   English

远程连接到cpanel中的mysql数据库

[英]remote connect to mysql database in cpanel

I have an app in C# and i want to remote connect to mysql database in cpanel my code is : 我在C#中有一个应用程序,我想远程连接到cpanel中的mysql数据库,我的代码是:

static string MyConString = SERVER= remoteDomin.com;DATABASE=XXX;UID=XXX;PASSWORD=XXX;";
MySqlConnection connection = new MySqlConnection(MyConString);

but this cann't succeed and throw MySql.Data.MySqlClient.MySqlException : 但这不能成功并抛出MySql.Data.MySqlClient.MySqlException

Access denied for user 'XXXr'@'adsl-109-74-46-204.dynamic.yemennet.ye' (using password: YES) 用户'XXXr'@'adsl-109-74-46-204.dynamic.yemennet.ye'的访问被拒绝(使用密码:是)

What do you mean "in cpanel?" 您在cpanel中是什么意思? Is your MySQL server running at a hosting provider? 您的MySQL服务器是否在托管服务提供商处运行? Is your client on your local machine? 您的客户端在本地计算机上吗? If so, that means you're trying to connect between your MySQL client and the server via the public internet. 如果是这样,则意味着您正在尝试通过公共互联网在MySQL客户端和服务器之间建立连接。 It certainly looks like this is what you're trying to do. 显然,这就是您要尝试执行的操作。

A lot of hosting providers don't allow this. 许多托管服务提供商不允许这样做。 Yours does, because the message you're getting says that the MySQL server is rejecting your particular connection request. 您这样做,因为您收到的消息表明MySQL服务器正在拒绝您的特定连接请求。

You need to grant access privileges in your MySQL data base so 您需要在MySQL数据库中授予访问权限,因此

XXXr@%

or maybe 或者可能

XXXr@adsl-109-74-46-204.dynamic.yemennet.ye

can get access to your database. 可以访问您的数据库。 The first choice grants access to the user XXXr attempting to connect from any host. 首选选项将授予尝试从任何主机进行连接的用户XXXr访问权限。 The second mentions the hostname that goes with your current ADSL access IP number. 第二个提到与您当前的ADSL访问IP号码一起使用的主机名。

If you can't figure out how to grant this user privilege (also known as user access) via your cpanel, ask you hosting provider's tech support for help. 如果您不知道如何通过cpanel授予此用户特权(也称为用户访问权限),请向托管服务提供商的技术支持寻求帮助。

It's possible your hosting provider -- the service that runs the MySQL server and provides cpanel access to it -- won't allow this. 您的托管服务提供商(运行MySQL服务器并提供对它的cpanel访问的服务)可能不允许这样做。 It's generally considered somewhat insecure to allow MySQL database connections from the public internet. 通常认为允许来自公共互联网的MySQL数据库连接有些不安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM