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

后端 未结 1 485
盖世英雄少女心
盖世英雄少女心 2021-01-16 08:27

I\'m a web dev rookie and I\'m hoping someone with more experience can help sort this out. I was ambushed by a MySQL upgrade.

Background: I have tw

相关标签:
1条回答
  • 2021-01-16 09:01

    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.

    0 讨论(0)
提交回复
热议问题