The host 127.0.0.1 does not support SSL connections.

  • 问题描述:如下代码会抛异常:The host 127.0.0.1 does not support SSL connections.
            string str = "Database=msgboard;Data Source=127.0.0.1;";//SslMode=none;
            str += "User Id=root;port=3306";
            sqlConn = new MySqlConnection(str);
            try
            {
                sqlConn.Open();
                Console.WriteLine("数据库连接成功");
            }catch(Exception ex)
            {
                Console.WriteLine("[数据库]连接失败"+ex.Message);
            }

  • 解决方案,多了SslMode=none
            string str = "Database=msgboard;Data Source=127.0.0.1;SslMode=none;";
            str += "User Id=root;port=3306";
            sqlConn = new MySqlConnection(str);
            try
            {
                sqlConn.Open();
                Console.WriteLine("数据库连接成功");
            }catch(Exception ex)
            {
                Console.WriteLine("[数据库]连接失败"+ex.Message);
            }

  • 原因就懒得分析了,我亲测是有效。你不妨试试。
    原文作者:ACrazyer
    原文地址: https://www.jianshu.com/p/5a02720a337d
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞