System.Data.Entity.Core.ProviderIncompatibleException: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure. ---> System.Data.Entity.Core.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> MySql.Data.MySqlClient.MySqlException: Authentication to host '192.168.1.25' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'WIN-30UFVO1MIM' (using password: YES) ---> MySql.Data.MySqlClient.MySqlException: Access denied for user 'root'@'WIN-30UFVO1MIM' (using password: YES)
服務器及軟件環境(Mysql 5.6、windows 2008 R2 64位)。
根據這個提示按照網上通用的解決方法,修改Mysql數據庫中的user表localhost為%,修改后依然無效,通過可視化工具可以用Ip連接,但是部署的.Net Web程序依然無法訪問數據庫,根據日志查詢,錯誤信息如上。
大概知道是權限問題,折騰了幾番后問題依舊,最后使出殺手鐧重新安裝Mysql!!!
解決方法:
1、徹底卸載了Mysql 5.6,重新安裝,這次安裝時默認端口設為3307,因3306被占用,后來把占用3306端口的mysqld進程給禁用了,端口改為3306;
2、通過mysql可視化工具進行localhost連接,正常連接;修改Web.config連接串為localhost,網頁正常訪問,連接串為IP則不行;
3、通過localhost進入數據庫,執行SQL語句:update user set host='%' where user = 'root';
4、如果返回結果為:ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' ,則說明host已經有了%這個值;
5、再次執行SQL語句:flush privileges;
6、搞定!
注:如果以上方法依然不能解決,請查看服務器的防火牆及入站規則是否允許3306端口訪問;