c#连接MySQL8.0.18

版本:安装 MySql.Data 6.7.9(安装最新版本,我出现了问题)

连接测试:caching_sha2_password问题,

在navicat中通过

SHOW GLOBAL VARIABLES;

查看到default_authentication_plugin = caching_sha2_password(注:以下图片已经是修改后的了)

通过以下方式找到my.ini文件

打开后更改成

default_authentication_plugin=mysql_native_password

最后在navicat新建查询中执行

ALTER USER root IDENTIFIED WITH mysql_native_password BY '你的密码';

到此,我的问题解决;

有人说要在连接语句后加上

SslMode=None (我试了一下没成功)
 public MySqlConnection OpenConn()
        {
            
            string MyConStr = "server=127.0.0.1;port=3307;user=root;password=1234;database=shalegasids;";
      
            MySqlConnection conn = new MySqlConnection(MyConStr);
            if (conn.State == System.Data.ConnectionState.Closed)
                conn.Open();       
            return conn;
        }

 


版权声明:本文为cxl0525原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。