简体   繁体   中英

MySQL Connection from an IoT Edge Module

I use my machine as a simulated device.

I deployed a docker image as a module to the device where I want to connect to a MySQL instance.

But I have the following error:

Unable to connect to any of the specified MySQL hosts.

I build the connection like this:

public static MySqlConnection BuildConnection(MySqlProperties parameters)
{
    MySqlConnectionStringBuilder connString = new MySqlConnectionStringBuilder();
    connString.Server = parameters.Server;
    connString.Database = parameters.Database;
    connString.UserID = parameters.Username;
    connString.Password = parameters.Password;
    connString.Add("Allow User Variables", true);

    var connection = new MySqlConnection(connString.ToString());
    return connection;
}

and then execute

var conn = BuildConnection(props);
Console.WriteLine("opening connection to mysql ...");
conn.Open();
Console.WriteLine("Connection state: " + conn.State);

Is it possible to connect to that database ?

问题是没有为远程连接配置MySQL。

I'm about to get deep in this topic. As far as my understandings are, this error is expected, because you have to install the MySQL server as a module on the Edge run-time.

This Microsoft documentation provides instructions on storing data on the Edge with SQL Server. It is written that the same should work for MySQL, as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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