环境
.net7 MySQL8.0
报错提示:
未经处理的异常
System.AggregateException:“One or more errors occurred. (Authentication method 'caching_sha2_password' failed. Either use a secure connection, specify the server's RSA public key with ServerRSAPublicKeyFile, or set AllowPublicKeyRetrieval=True.)”
内部异常
SqlSugarException: Authentication method 'caching_sha2_password' failed. Either use a secure connection, specify the server's RSA public key with ServerRSAPublicKeyFile, or set AllowPublicKeyRetrieval=True.
解决方法:
数据库连接字符内加:AllowPublicKeyRetrieval=True
原数据库连接字符:Data Source=192.168.28.9;port=3306;User ID=MySQLName;Password=123456;Database=mdgk_zlfq;CharSet=utf8mb4;sslmode=none;AllowLoadLocalInfile=true;
添加后:Data Source=127.0.0.1;port=3306;User ID=MySQLName;Password=123456;Database=asdf;CharSet=utf8mb4;sslmode=none;AllowLoadLocalInfile=true;AllowPublicKeyRetrieval=True;
标签:set,C#,数据库,AllowPublicKeyRetrieval,MySQL8.0,True,连接 From: https://www.cnblogs.com/Prode/p/18469654