asp.net / MySQL的:拒绝访问用户''@'localhost'的(使用密码:NO) [英] asp.net / MySQL: Access denied for user ''@'localhost' (using password: NO)

查看:1348
本文介绍了asp.net / MySQL的:拒绝访问用户''@'localhost'的(使用密码:NO)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个Web开发新秀我希望有人与更多的经验,可以帮助排序了这一点。我被一个MySQL升级伏击。

背景:
我有两个XP的电脑(我们雄心勃勃地称他们为网络服务器和MySQL服务器)。我最近建成并成功地举办了从M​​ySQL数据库的数据画了一个asp.net网站。这只是针对少数本地用户,使他们不必学习SQL获取数据的网站...没有什么花哨。到目前为止好。

问题:
这一周,我的网络服务器上安装了MySQL,这是当事情陷入疯狂。曾有该点之前在Web服务器上一直没有的MySQL实例。由于安装我有:


  1. ...重新安装MySQL的.NET提供

  2. ...重新配置machine.config文件

  3. ...复制MySQL_Web.dll到MySQL的bin目录

  4. ...试图得到设置与下面的站点上的说明一致。

的http://开发。 mysql.com/doc/refman/5.0/en/connector-net-tutorials-asp-roles.html

这解决了一些问题,而我得到了现场部分并再次运行。我可以访问登陆页面,并为来宾用户查询返回数据确定。

错误消息#1
但是,当用户试图登录访问网站上的私人网页,我得到错误的访问被拒绝的用户''@'localhost'的(使用密码:NO)的。这显然​​是错误的,因为我使用的密码,因为没有连接字符串指向本地主机/网络服务器。唯一的连接字符串指向数据库所在MySQL服务器。

错误消息#2
我也期待在asp.net网站管理工具在安全选项卡,看到了以下错误:

有与所选的数据存储的一个问题,这可以通过一个无效的服务器的名称或凭证,或经许可不足所引起的。它也可以由该角色管理器功能造成不被启用。单击下面的按钮被重定向到一个页面,您可以选择一个新的数据存储下面的消息可能在诊断问题帮助:发生异常请检查事件日志

角色管理器绝对是启用,并且供应商的设置是否正确。

我试过在Web服务器上卸载的MySQL,重新创建该网站的用户表,冲洗特权和一些其他的招数,但该网站现在似乎日志中的过程和搜索过程中被永久绕过连接字符串中的数据库Web服务器来代替。

有没有人有,我可以拿这下什么想法?我已经难倒了几天,我不知道还有什么我能做的。


编辑:供应相关的code作为请在下面的意见。如前所述,这是作为默认项目的一部分产生的所有标准code,并没有以任何方式修改过(除了当然的web.config)。

的Web.config

 <&是connectionStrings GT;
   <清除NAME =MySQLWebConnection/>
   <添加名称=MySQLWebConnection的connectionString =服务器= MyWebServer的;用户ID = MYNAME;密码= MYPWD;数据库= MYDB的providerName =MySql.Data.MySqlClient/>
< /&是connectionStrings GT;
<&的System.Web GT;
   <会员defaultProvider =MySQLMembershipProvider/>
   < roleManager启用=真正的defaultProvider =MySQLRoleProvider/>
   <身份验证模式=表格>
    <形式的名称=。ASPXFORMSAUTHloginUrl =〜/帐号/的Login.aspxdefaultUrl =〜/ Default.aspx的/>
   < /认证>
   ...
< /system.web>

的Login.aspx

 < ASP:登录ID =LoginUser=服务器的EnableViewState =假RenderOuterTable =false的>
        <&LayoutTemplate模板GT;
            <跨度类=failureNotification>
                < ASP:文字ID =FailureText=服务器>< / ASP:文字>
            < / SPAN>
            < ASP:的ValidationSummary ID =LoginUserValidationSummary=服务器的CssClass =failureNotification
                 的ValidationGroup =LoginUserValidationGroup/>
            < D​​IV CLASS =accountInfo>
                <字段集类=登录>
                    <传奇>帐户信息与LT; /传说>
                    &所述p为H.;
                        < ASP:标签ID =UserNameLabel=服务器AssociatedControlID =用户名>用户名:​​其中; / ASP:标签>
                        < ASP:文本框ID =用户名=服务器的CssClass =TEXTENTRY>< / ASP:文本框>
                        < ASP:的RequiredFieldValidator ID =UserNameRequired=服务器的ControlToValidate =用户名
                             的CssClass =failureNotification的ErrorMessage =用户名是必需的。工具提示=用户名是必需的。
                             的ValidationGroup =LoginUserValidationGroup> * LT; / ASP:&的RequiredFieldValidator GT;
                    &所述; / P>
                    &所述p为H.;
                        < ASP:标签ID =PasswordLabel=服务器AssociatedControlID =密码>密码:LT; / ASP:标签>
                        < ASP:文本框ID =密码=服务器的CssClass =passwordEntry的TextMode =密码>< / ASP:文本框>
                        < ASP:的RequiredFieldValidator ID =PasswordRequired=服务器的ControlToValidate =密码
                             的CssClass =failureNotification的ErrorMessage =密码是必需的。工具提示=密码是必需的。
                             的ValidationGroup =LoginUserValidationGroup> * LT; / ASP:&的RequiredFieldValidator GT;
                    &所述; / P>
                    &所述p为H.;
                        < ASP:复选框ID =了rememberMe=服务器可见=假/>
                        < ASP:标签ID =RememberMeLabel=服务器可见=假AssociatedControlID =了rememberMe的CssClass =内联>保持登入上述< / ASP:标签>
                    &所述; / P>
                < /字段集>
                < p =类提交按钮>
                    < ASP:按钮的ID =LoginButton=服务器的CommandName =登录文本=登录的ValidationGroup =LoginUserValidationGroup/>
                &所述; / P>
            < / DIV>
        < / LayoutTemplate模板>
    < / ASP:登录>


解决方案

解决。希望这可以帮助其他人有类似的问题,并简化沿途几个偏头痛。纯粹的恐慌一周给我留下了寻求神的介入,当一切都失败了,所以这个大家伙楼上得到这一个复选标记。 :)

原因:
重新安装MySQL和.NET连接器意味着machine.config文件自定义被改写。

解决方案:
更新后,请确保以下两个变化都发生在machine.config文件...

(1)

 <会员和GT;
   <供应商>
      <添加名称=MySQLMembershipProvider** autogenerateschema =真正的** ... />
   < /供应商>
< /会员>

(2)

 <&是connectionStrings GT;
  <添加名称=LocalMySqlServer的connectionString =服务器= DBSERVER;用户ID = myUserID;密码= MYPASSWORD;数据库= MyDatabase的/>
< /&是connectionStrings GT;

这是被绊倒了我第二个。在重新安装code已改为...

 <&是connectionStrings GT;
   <添加名称=LocalMySqlServer的connectionString =/>
< /&是connectionStrings GT;

...这就是为什么该网站是试图连接到本地主机,为什么在web.config中的ConnectionString用户信息是被忽略。

祝大家! :)

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 two XP PCs (let's ambitiously call them "web server" and "MySQL server"). I recently built and successfully hosted an asp.net site that drew data from the MySQL db. It's just a site designed for a few local users so they don't have to learn SQL to get data...nothing fancy. So far so good.

Problem: This week I installed MySQL on the "web server", and that's when things went crazy. There had been no instance of MySQL on the web server before that point. Since the install I've:

  1. ...reinstalled the MySQL .NET provider
  2. ...reconfigured the machine.config file
  3. ...copied the MySQL_Web.dll to the MySQL bin directory
  4. ...attempted to get the setup to align with the directions in the site below.

http://dev.mysql.com/doc/refman/5.0/en/connector-net-tutorials-asp-roles.html

This addressed a number of issues, and I got the site partially up and running again. I can access the landing page, and queries for guest users are returning data ok.

Error Message #1 However, when the user tries to log in to access private pages on the site, I get the error "Access denied for user ''@'localhost' (using password: NO)". This is clearly wrong since I'm using a password, and because there is no connection string pointing to the localhost/web server. The only connection string points to the MySQL server where the database resides.

Error Message #2 I'm also looking at the asp.net Web Site Administration Tool in the Security tab and seeing the following error:

"There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store. The following message may help in diagnosing the problem: An exception occurred. Please check the Event Log."

The role manager is definitely enabled, and the providers are correctly set up.

I've tried uninstalling MySQL on the web server, recreating the site's user tables, flushing privileges and a few other tricks, but the site now seems to be permanently bypassing the db in the connection string during the log in process and searching the web server instead.

Does anyone have any ideas where I can take this next? I've been stumped for a few days, and I don't know what else I can do.


Edit: Supplying the relevant code as asked in the comments below. As noted, this is all standard code generated as part of a default project, and hasn't been edited in any way (except for web.config of course).

Web.config

<connectionStrings>
   <remove name="MySQLWebConnection"/>
   <add name="MySQLWebConnection" connectionString="server=myWebServer;User Id=myName;password=myPwd;database=myDB" providerName="MySql.Data.MySqlClient"/>
</connectionStrings>


<system.web>
   <membership defaultProvider="MySQLMembershipProvider" />
   <roleManager enabled="true" defaultProvider="MySQLRoleProvider" />
   <authentication mode="Forms">
    <forms name=".ASPXFORMSAUTH" loginUrl="~/Account/Login.aspx" defaultUrl="~/Default.aspx" />
   </authentication>
   ...
</system.web>

Login.aspx

   <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
        <LayoutTemplate>
            <span class="failureNotification">
                <asp:Literal ID="FailureText" runat="server"></asp:Literal>
            </span>
            <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" 
                 ValidationGroup="LoginUserValidationGroup"/>
            <div class="accountInfo">
                <fieldset class="login">
                    <legend>Account Information</legend>
                    <p>
                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
                        <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" 
                             CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." 
                             ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                        <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" 
                             CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." 
                             ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                    </p>
                    <p>
                        <asp:CheckBox ID="RememberMe" runat="server" Visible="false" />
                        <asp:Label ID="RememberMeLabel" runat="server" Visible="false" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
                    </p>
                </fieldset>
                <p class="submitButton">
                    <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/>
                </p>
            </div>
        </LayoutTemplate>
    </asp:Login>

解决方案

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.

Good luck everyone! :)

这篇关于asp.net / MySQL的:拒绝访问用户''@'localhost'的(使用密码:NO)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆