C#连接MySQL异常:The host localhost does not support SSL connections.

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/OnlyRu/article/details/82117860

解决方案: 

    连接字符串添加如下语句.

SslMode = none;
 
  1. static void Main(string[] args)

  2. {

  3. Console.WriteLine("123");

  4.  
  5. string connectstr="server=localhost;port=3306;database=test;user=root;password=;SslMode = none;";

  6. MySqlConnection conn=new MySqlConnection(connectstr);

  7.  
  8. try {

  9. conn.Open();

  10. Console.WriteLine("连接成功!!!");

  11. } catch (Exception e) {

  12.  
  13. Console.WriteLine(e.ToString());

  14. }finally{

  15. conn.Close();

  16. Console.WriteLine("正常关闭!!!");

  17. }

  18.  
  19. Console.ReadKey();

  20. }

猜你喜欢

转载自blog.csdn.net/OnlyRu/article/details/82117860
今日推荐