C# 連mysql時,出現mysql_native_password

DB名稱異常

MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host '**IP地址**' for user '**有戶名**' using method 'mysql_native_password' failed with message: Access denied for user 'lrmis'@'%' to database 'maildb1' ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Access denied for user 'lrmis'@'%' to database 'maildb1'

MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host '**IP地址**' for user '**有戶名**' using method 'mysql_native_password' failed with message: Reading from the stream has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Reading from the stream has failed. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.

此異常偶爾出現,網上介紹連接字符串加上sslmode=none; 待觀察驗證

正常情況下是連接字符串不對時,每次都會出現此異常 ,寫不正確的db名稱

 return string.Concat(new string[]
			{
				"Database='",
				this._DBName,
				"';Data Source='",
				this._ServerName,
				"';Persist Security Info=True;min pool size=20;max pool size=10240;Connection Timeout = 15;CharSet=UTF8mb4;Pooling=true;User Id='",
				this._LoginUser,
				"';Password='",
				this._PassWord,
				"';charset='utf8mb4';pooling=true;sslmode=none;"
			});

 

猜你喜欢

转载自blog.csdn.net/losedguest/article/details/84026043