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端口访问;