I have an ASP.NET MVC4 site using EF 5.0 and MySQL for the db. Everything works great on my development PC, yet when I make a build of the site for my Windows 2008 Web Server SP2, with IIS7, I get the following error...
我有一个使用EF 5.0和MySQL的ASP.NET MVC4站点。一切都在我的开发PC上运行良好,但是当我使用IIS7为我的Windows 2008 Web Server SP2构建网站时,我收到以下错误...
Access denied for user 'root'@'::1' (using password: NO)
用户'root'@':: 1'访问被拒绝(使用密码:否)
Now, what is baffling here is this problem is fixed by providing a password in the connection string (which I have), so I have no idea why I would still get this error.
现在,令人困惑的是这个问题是通过在连接字符串(我有)中提供密码来解决的,所以我不知道为什么我仍会得到这个错误。
My connection string in my web.config is:
我在web.config中的连接字符串是:
metadata=res:///MyModel.csdl|res:///MyModel.ssdl|res://*/MyModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=root;password=1234;persist security info=True;port=3307;database=MyDb"
metadata = res:///MyModel.csdl | res:///MyModel.ssdl | res://*/MyModel.msl; provider = MySql.Data.MySqlClient; provider connection string =“server = localhost; user id = root; password = 1234; persist security info = True; port = 3307; database = MyDb“
2 个解决方案
#1
0
Try changing your connection string to
尝试将连接字符串更改为
metadata=res:///MyModel.csdl|res:///MyModel.ssdl|res://*/MyModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=root;password=1234;persist security info=True;port=3307;database=MyDb"
metadata = res:///MyModel.csdl | res:///MyModel.ssdl | res://*/MyModel.msl; provider = MySql.Data.MySqlClient; provider connection string =“server = localhost; user id = root; password = 1234; persist security info = True; port = 3307; database = MyDb“
Your connectin string had no closing "
你的连接字符串没有关闭“
#2
0
I managed to resolve this... strangely, 'localhost' works for regular MySQL connections to the database (I use it in ASP.NET websites without EF).
我设法解决了这个问题......奇怪的是,'localhost'适用于与数据库的常规MySQL连接(我在没有EF的ASP.NET网站中使用它)。
But now using EF, it seems specifically putting 127.0.0.1 as the server instead of localhost fixes the issue.
但是现在使用EF,似乎特意将127.0.0.1作为服务器而不是localhost修复了这个问题。
Very strange indeed!
确实很奇怪!
#1
0
Try changing your connection string to
尝试将连接字符串更改为
metadata=res:///MyModel.csdl|res:///MyModel.ssdl|res://*/MyModel.msl;provider=MySql.Data.MySqlClient;provider connection string="server=localhost;user id=root;password=1234;persist security info=True;port=3307;database=MyDb"
metadata = res:///MyModel.csdl | res:///MyModel.ssdl | res://*/MyModel.msl; provider = MySql.Data.MySqlClient; provider connection string =“server = localhost; user id = root; password = 1234; persist security info = True; port = 3307; database = MyDb“
Your connectin string had no closing "
你的连接字符串没有关闭“
#2
0
I managed to resolve this... strangely, 'localhost' works for regular MySQL connections to the database (I use it in ASP.NET websites without EF).
我设法解决了这个问题......奇怪的是,'localhost'适用于与数据库的常规MySQL连接(我在没有EF的ASP.NET网站中使用它)。
But now using EF, it seems specifically putting 127.0.0.1 as the server instead of localhost fixes the issue.
但是现在使用EF,似乎特意将127.0.0.1作为服务器而不是localhost修复了这个问题。
Very strange indeed!
确实很奇怪!