asp.net C# 連接MySQL8.0的caching_sha2_password問題
解(jie)決方法可用以下命令:
命令(ling)行登錄mysql; mysql>use mysql; mysql>ALTER USER root IDENTIFIED WITH mysql_native_password BY '你的(de)密碼(ma)'; mysql>FLUSH PRIVILEGES;
網上說用:
MySql 8.0 C#連(lian)接報(bao)錯 MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host 'xxx' for user 'root' using method 'caching_sha2_password' failed with message: Reading from t 解(jie)決方法 在連接字符串(chuan)后面加上 SslMode=None
以(yi)上方法未成功,可能還是mysql 8.0密碼驗證機制問題導致,所以(yi)需要修改一下my.ini文(wen)件如下:
如(ru)果(guo)安裝(zhuang)目錄下(xia)找不到my.ini文(wen)件 windows系統(tong)下(xia)處理如(ru)下(xia),打開C盤 查(cha)看選項中,查(cha)看隱藏文(wen)件,如(ru)果(guo)不出意(yi)外在programeData下(xia)(C:\ProgramData\MySQL\MySQL Server 8.0)找到my.ini
加入這一項 default_authentication_plugin=mysql_native_password
然后在(zai)服務中重啟MySQL80服務
[mysqld]
default_authentication_plugin=mysql_native_password
Linux 下可(ke)以修改(gai)在/etc/my.cnf文件