部署系统,出现下面异常错误 :
异常: Authentication method 'caching_sha2_password' not supported by any of the available plugins.
来源: MySql.Data
实例: 在 MySql.Data.MySqlClient.Authentication.AuthenticationPluginManager.GetPlugin(String method)
在 MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.GetPlugin(String method, NativeDriver driver, Byte[] authData)
在 MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset)
在 MySql.Data.MySqlClient.NativeDriver.Open()
在 MySql.Data.MySqlClient.Driver.Open()
在 MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
在 MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
在 MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
在 MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
在 MySql.Data.MySqlClient.MySqlPool.GetConnection()
在 MySql.Data.MySqlClient.MySqlConnection.Open()
在 MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection connection)
在 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
解法:
在因之前是mysql5.7,现换成mysql8,8的登陆加密规则与5.7的不一样,导致用户验证方法通过,所以有上面异常。以在mysql8的服务器上,到C:\ProgramData\MySQL\MySQL Server 8.0目录下,找到my.ini文件,在# The default authentication plugin to be used when connecting to the server的下面加default_authentication_plugin=mysql_native_password设置,8的验证方法是caching_sha2_password,要改成5.7的mysql_native_password。
(注意:C:\ProgramData是隐藏目录,直接将路径在文件夹中拷入)
# The default authentication plugin to be used when connecting to the server
#caching_sha2_password
default_authentication_plugin=mysql_native_password
保存my.ini后,在任务管理器里,右击MySQL80服务,重启服务。