mysql Access denied for user 'root'@'localhost' (using password: YES),deniedlocalhost

來源:互聯網
上載者:User

mysql Access denied for user 'root'@'localhost' (using password: YES),deniedlocalhost

【現象說明】

C/S程式遠端存取正常,本地訪問報以下異常

MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'localhost' (using password: YES) ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Access denied for user 'root'@'localhost' (using password: YES)

設定檔如下:

<add name="RemoteConnString" connectionString="Database='mealbooker';Data Source='localhost';User Id='root';Password='123456';charset='gb2312';pooling=true" providerName="MySql.Data.MySqlClient"/>


【分析】

許可權問題吧,查看下mysql資料庫中的user表


發現localhost下面值為空白,於是connection string中的localhost 改為 127.0.0.1,測試通過~~~

【解決】


設定檔中改為localhost,訪問資料庫正常;同時mysql command line工具輸入密碼後一閃而過問題同時解決。


另,mysql command line工具一閃而過,方法參見這裡


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.