1. Entity Framework Core 连接 MySql
连接数据库出现以下错误:
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure()' to the 'UseMySql' call.
版本问题,使用自动检测版本方法
var connectionString = configuration.GetConnectionString(connectStr); services.AddDbContext<T>(options => { options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); });
2. 认证问题
MySql 8.0 默认使用 caching_sha2_password 插件认证,解决方法:
. https://mysqlconnector.net/troubleshooting/retrieval-public-key/#:~:text=To%20retrieve%20the%20server%E2%80%99s%20public%20key%2C%20connect%20securely,to%20the%20connection%20string%3B%20this%20is%20potentially%20insecure.
. 修改认证
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Your New Password'; FLUSH PRIVILEGES;
标签:20the%,遇到,UseMySql,connectionString,认证,使用,password,MySql From: https://www.cnblogs.com/huangzhengguo/p/17207698.html