mysql allows blank username and password

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil W

    mysql allows blank username and password

    Hi, I'm a bit of a newbie to PHP and mySQL. I'm trying to get things running
    on my W2K machine.

    I'm having a problem using the mysql_connect() function (although the
    problem's probably rooted in mysql). When trying to log in via PHP with the
    code "$link = mysql_connect(" localhost", "phil", "pwpass123" );" I get the
    error...

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user:
    'phil@localhost ' (Using password: YES) in c:\inetpub\wwwr oot\php\mysql.p hp
    on line 9

    The thing is that it connects ok if I leave the username and password blank.
    The ones I'm using above are ones I specified in mysqladmin when I first ran
    it.

    Can anyone help me 1) Stop mysql accepting blank username and password
    values, and 2) get it to accept my defined username and password?

    Many thanks in advance,
    Phil


  • Peter Taurins

    #2
    Re: mysql allows blank username and password

    I would hazard a guess that you haven't granted phil the right permissions.

    mysql -- user=root mysql
    GRANT ALL PRIVEILEGES ON *.* TO user@localhost IDENTIFIED BY 'password' WITH
    GRANT OPTION;

    I would also guess that root (which is the default) doesn't have a password
    set up which is why that works.

    HTH.
    PWT.



    "Phil W" <me@privacy.net > wrote in message
    news:bj9qct$gth 67$1@ID-180242.news.uni-berlin.de...[color=blue]
    > Hi, I'm a bit of a newbie to PHP and mySQL. I'm trying to get things[/color]
    running[color=blue]
    > on my W2K machine.
    >
    > I'm having a problem using the mysql_connect() function (although the
    > problem's probably rooted in mysql). When trying to log in via PHP with[/color]
    the[color=blue]
    > code "$link = mysql_connect(" localhost", "phil", "pwpass123" );" I get the
    > error...
    >
    > Warning: mysql_connect() [function.mysql-connect]: Access denied for user:
    > 'phil@localhost ' (Using password: YES) in c:\inetpub\wwwr oot\php\mysql.p hp
    > on line 9
    >
    > The thing is that it connects ok if I leave the username and password[/color]
    blank.[color=blue]
    > The ones I'm using above are ones I specified in mysqladmin when I first[/color]
    ran[color=blue]
    > it.
    >
    > Can anyone help me 1) Stop mysql accepting blank username and password
    > values, and 2) get it to accept my defined username and password?
    >
    > Many thanks in advance,
    > Phil
    >
    >[/color]


    Comment

    • Gary Petersen

      #3
      Re: mysql allows blank username and password

      A Martian named "Phil W" <me@privacy.net > telepathically imparted message
      <bj9qct$gth67$1 @ID-180242.news.uni-berlin.de> to us on Fri, 05 Sep 2003
      05:59:23 -0500:
      [color=blue]
      > [snipped mysql login error]
      > The thing is that it connects ok if I leave the username and password
      > blank. [...][/color]

      Delete the "test" database and make sure that the
      "root" user (in mysql) has a password.

      By default, anonymous users have access to databases
      that start with "test" (I think).

      For your login problem, perhaps you are using the wrong
      password. See if you can change it with mysqladmin.

      Comment

      • Phil W

        #4
        Re: mysql allows blank username and password

        "Gary Petersen" <garyp1492@remo ve.meearthlink. invalid> wrote in message
        news:pan.2003.0 9.07.05.42.01.1 86772.260@REMOV E.MEearthlink.I NVALID...[color=blue]
        > Delete the "test" database and make sure that the
        > "root" user (in mysql) has a password.
        >
        > By default, anonymous users have access to databases
        > that start with "test" (I think).
        >
        > For your login problem, perhaps you are using the wrong
        > password. See if you can change it with mysqladmin.[/color]

        Cheers Gary, I ended up going back to square one and doing just that.

        Also, I think I was getting mixed up with the winmysqladmin - the username
        password defined there seems to just get dropped into the my.ini file for
        login, whereas I originally thought it was setting that user up too. I could
        well be wrong about that though! I think I need to get one of those "for
        dummies" books on mysql!


        Comment

        Working...