1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

MYSQL denying access despite correct password and username

Discussion in 'MySQL' started by lawmaina78, Sep 10, 2007.

  1. #1
    Please help,
    Have tried to configure my new site which uses mysql unsuccessfully. I have a config.php file which has all the connections parameters. i created a Database and user then gave all the privileges to this user. w I have specified in the config file the user info. Am getting this kind of error;

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in /home/domain/public_html/config/config.php on line 11
    Access denied for user 'username'@'localhost' (using password: YES)

    I have tried recreating the whole thing again and again to no success.

    I used the same details in another server and everything worked perfectly.

    Please I will appreciate your help.
     
    lawmaina78, Sep 10, 2007 IP
  2. mariush

    mariush Peon

    Messages:
    562
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's a well known problem with authentification between PHP and MySQL.

    You may have to change the password hash from the new format to the older format used by MySQL in order to have PHP able to connect.

    Run this on you mysql server:

    
    UPDATE mysql.user SET password=old_password("youroldhashpassword") WHERE user ='youruserid' and host ='yourhost'
    
    Code (markup):
    youroldhashpassword is the password you've set
    youruserid is your username (most likely 'root' if running on Windows)
    yourhost is most likely localhost

    You can see all users on your database by running this on database "mysql":
    
    SELECT * FROM `user` 
    
    Code (markup):
    More info :

    http://www.php.net/mysql_connect
    http://www.digitalpeer.com/id/mysql
    http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html

    PS. After you update to the older password hashing using OLD_PASSWORD() you *may* have to run :
    
    FLUSH PRIVILEGES
    
    Code (markup):
    I never had to.
     
    mariush, Sep 11, 2007 IP
    usasportstraining likes this.
  3. litebulb1

    litebulb1 Peon

    Messages:
    151
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Instead of using localhost for the server address you can try and use the IP address.
     
    litebulb1, Sep 14, 2007 IP