MySQL访问被拒绝#1045 [重复]

This question already has an answer here:

Can anyone please help me with this. I cannot access phpMyAdmin. I am using WAMPSERVER 2.4 and running Windows 7 32-bit OS.

Everytime I try to access phpMyAdmin it gives an error like this:

Error MySQL said: Documentation

1045 - Access denied for user 'root'@'localhost' (using password: NO)

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

</div>

Edit your phpmyadmin config.inc.php file :

$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = '**your-root-username**';
$cfg['Servers'][$i]['password'] = '**root-password**';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

Like all versions of MySQL after initially installing it there is only one User account available.

The username is root and there is no password on this account.

So on the login page for phpMyAdmin enter:

username = root
password = leave this empty

Once you are logged in, add a password to this account. And dont forget it!

Once you have set a password, and tested that you can login again with that password you can make a simple change to this file:

c:\wamp\www\apps\phpmyadminx.y.z\config.inc.php

Look for :

$cfg['Servers'][$i]['AllowNoPassword'] = true;

and chnage it to

$cfg['Servers'][$i]['AllowNoPassword'] = false;

This will stop phpmyadmin allowing access using a userid that does not have a password.