简体   繁体   English

具有自签名的C#连接mysql

[英]C# Connection mysql with self signed

Is self signed certificate disrupting connection to mysql? 自签名证书会中断与mysql的连接吗? I already give action crud in data and grant access to administration. 我已经采取行动处理数据并授予管理权限。

but the connection still got error. 但是连接仍然出错。

Unable to connect to any of the specified MySQL hosts 无法连接到任何指定的MySQL主机

my team connection like this: 我的团队联系如下:

Catalog=devbaf;User Id=userclient;password=client123

connection code: 连接代码:

  try
        {
            string constring = "SERVER=123.45.678.9;DATABASE=devbaf;User Id=backendsystem;PASSWORD=1q2w3e4r5t;";
            using (MySqlConnection con = new MySqlConnection(constring))
            {
                using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM users"))
                {
                    using (MySqlDataAdapter sda = new MySqlDataAdapter())
                    {
                        cmd.Connection = con;
                        sda.SelectCommand = cmd;
                        using (DataTable dt = new DataTable())
                        {
                            sda.Fill(dt);
                            gvtest.DataSource = dt;
                            gvtest.DataBind();
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            Response.Write(e.Message.ToString());
        }

explanation problem: 解释问题:

I make a database in local server, so my friend can access to it to insert data. 我在本地服务器上建立数据库,所以我的朋友可以访问它以插入数据。 but when he make a connection script it wont connect to my database but can connect to server. 但是当他创建连接脚本时,它不会连接到我的数据库,但可以连接到服务器。 He already tries to move some file to the server and it works,but the connection to database wont connect. 他已经尝试将某些文件移动到服务器上并且可以运行,但是与数据库的连接无法连接。 i don't have an experience for this coz im php programmer not c# programmer. 我没有这个COZ IM PHP程序员而不是C#程序员的经验。 hope my explanation is clear. 希望我的解释清楚。

I have found your error message like trying to connect the host but in your connection string is missing the MySQL server name or host address. 我发现了您的错误消息,例如尝试连接主机,但连接字符串中缺少MySQL服务器名称或主机地址。 I hope if you add the MySQL hostname or server address to your connection. 我希望您将MySQL主机名或服务器地址添加到连接中。 it will fix your issue. 它将解决您的问题。

you can try this 你可以试试这个

string connectionString ="SERVER=servername; DATABASE=databasename; User Id=userid; PASSWORD=password;";

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

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