连接远程mysql数据库,收到错误"无法连接到任何指定的MySQL主机"

R.V*_*tor 3 c# mysql database mysql-connector

我正在创建一个连接到远程mysql数据库的应用程序到一些cpanel帐户.我在cpanel帐户上创建了数据库,并为其定义了用户名和密码.我正在使用MysqlConnector.到目前为止,我已经编写了以下代码:

using MySql.Data.MySqlClient;
        MySqlConnection c = new MySqlConnection("SERVER = 64.191.12.54; DATABASE = alyataco_test4application; User ID = xxxxxxxx; PASSWORD = xxxxxxxx");
        c.Open();
Run Code Online (Sandbox Code Playgroud)

但是我得到了错误:

MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
Run Code Online (Sandbox Code Playgroud)

我还看到使用Visual C#连接到远程MySQL数据库,但也没有帮助

Mat*_*ieu 7

你的连接字符串似乎错了.尝试:

MySqlConnection c = new MySqlConnection("server=64.191.12.54; database=alyataco_test4application; uid=xxxxxxxx; pwd=xxxxxxxx");
Run Code Online (Sandbox Code Playgroud)

有关更多连接字符串示例,请参见http://www.connectionstrings.com/mysql.