#1045 – Access denied for user ‘root’@’localhost’ (using password: NO)

That error means that a webpage is accessing a server that has a password, but is not using one. root@localhost has a password and your mysql_connect() doesn’t have a password parameter. It happens generally when you change the password or user root using phpmyadmin.

Solution:

1) Go to C:\wamp\apps\phpmyadmin3.2.0.1

2) Open the ‘config.inc.php’ file in editor like Notepad and match the following lines with the parameters.

$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’] = ‘[Root User Name]’;
$cfg[‘Servers’][$i][‘password’] = ‘[Root password]’;
$cfg[‘Servers’][$i][‘AllowNoPassword’] = true;

3) Replace the ‘[Root User Name]’ and ‘[Root password]’; in the above lines with the root user’s user name of password.

4) Restart mysql service or restart computer

5) Enjoy…!!