phpMyAdmin access denied for user root

18,996

Solution 1

Yes change the config.inc file in the C:\wamp\apps\phpmyadmin3.4.10.1 path if you are using wamp server and change the password in the entry as below

$cfg['Servers'][$i]['password'] = 'root';   

Solution 2

Did you Flush Privileges after you edited and added your users? Until then MySQL will not know about the changes you did to the privileges table.

If you are using the 'config authentication mode' in phpmyadmin you have to edit the config file to use the new user/password. See here for more info about the config modes.

Look for $cfg['Servers'][$i]['auth_type'] = 'config'; in your config.inc.php and then edit the following to your new user credentials:

$cfg['Servers'][$i]['user'] = 'your-user-here';
$cfg['Servers'][$i]['password'] = 'your-password-here';

Be sure to secure the login because your using automatic login ;)

Solution 3

When you "removed the rest of the accounts", it sounds like you deleted the root account too. If the new user you created has full access to the DB, you can recreate the root account with that user (if you want). Otherwise, you'll have to re-add the root user. If you read these instructions, you should get the idea of how to do it (the instructions are about resetting the root password, but you'll see which tables and commands are involved).

Share:
18,996
John
Author by

John

Updated on July 11, 2022

Comments

  • John
    John almost 2 years

    phpMyAdmin worked fine with username 'root' and with no password. I decided to create a new user 'username', 'password' with host 'Any', then I removed the rest of accounts. Now when I access "mydomain/phpmyadmin" it shows #1045 - Access denied for user 'root'@'localhost' (using password: NO)

    how can I access it with my username/pass?

  • John
    John over 12 years
    what's about php login? I can't login using mysql_connect() and I don't know why..
  • lorem monkey
    lorem monkey over 12 years
    Because you didn't flush the privileges (see the link for more knowledge about user management in mysql)! Your database just won't know about the changes.