asp.net / MySQL: Access denied for user ''@'localhost' (using password: NO)

自闭症网瘾萝莉.ら 提交于 2019-12-01 13:22:13
user2009790

Solved. Hopefully this helps someone else with similar problems, and eases a few migraines along the way. A week of sheer panic left me seeking divine intervention when all else had failed, so the big guy upstairs gets the checkmark for this one. :)

Cause: Re-installing MySQL and the .NET connector meant the machine.config file customizations were overwritten.

Solution: After the updates, make sure the following two changes are in place in the machine.config file...

(1)

<membership>
   <providers>
      <add name="MySQLMembershipProvider" **autogenerateschema="true"** ... />
   </providers>
</membership>      

(2)

<connectionStrings>
  <add name="LocalMySqlServer" connectionString="server=dbServer;User Id=myUserID;password=myPassword;database=myDatabase" />
</connectionStrings>

It was the second one that was tripping me up. During the reinstall the code had been changed to...

<connectionStrings>
   <add name="LocalMySqlServer" connectionString="" />
</connectionStrings>

...which is why the site was attempting to connect to the localhost, and why the user info in the web.config connectionstring was being ignored.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!