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

Hello,
I am new to creating web sites in general. However I have created one with dreamweaver cs4. I am now attempting to create some user registration/login stuff. But, I am receiving this error when I try to log into PHPMyAdmin:

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

I have tried following the steps located @ http://www.sitepoint.com/forums/showthread.php?t=540980 but still the same error.

here is a copy of my config.inc.php :

<?php

/* Servers configuration */
$i = 0;

/* Server: localhost [1] /
$i++;
$cfg[‘Servers’][$i][‘verbose’] = ‘localhost’;
$cfg[‘Servers’][$i][‘host’] = ‘localhost’;
$cfg[‘Servers’][$i][‘port’] = ‘’;
$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’;
$cfg[‘Servers’][$i][‘password’] = '
********';
$cfg[‘Servers’][$i][‘AllowNoPasswordRoot’] = false;

/* End of servers configuration */

$cfg[‘DefaultLang’] = ‘en-utf-8’;
$cfg[‘ServerDefault’] = 1;
$cfg[‘UploadDir’] = ‘’;
$cfg[‘SaveDir’] = ‘’;

?>

As you can see I do have my password in there … Can anyone help?

I am using wampserver 2.0 and phpmyadmin 3.2.0.1

Thank you, in advance, for your time:

Rick

First of all, I personally like to fill in sensative information such as passwords with “xxxx” when posting it on a forum.

The error ‘#1045 - Access denied for user ‘root’@‘localhost’ (using password: NO)’ means that no password is being used to try to log in to the SQL server.

May we see the PHP code you are using to try to make the connection?

This happens when I click on phpmyadmin inside wampserver control panel on my desktop.

Thanks for the password tip , I have changed it.

I am trying to set everything up in order to create a user registration and protected pages.

I’ve been trying to set up and development environment (following the instructions in “Build your Own Database Driven Web Site…”) and I keep getting almost done but something doesn’t work. I tried the individual installs but couldn’t get phpMyAdmin to connect to MySQL. It said that MySQL wasn’t installed, even though it was. I tried a number of ideas in these threads to no avail.

So I removed everything and tried the all-in-one WAMP solution. It appears to work, except for phpMyAdmin, which gives me the error: #1045 - Access denied for user ‘root’@‘localhost’ (using password: NO). I can access the SQL admin cmd-line program without any trouble.

In either case, is it something in a phpMyAdmin config file that I just keep missing?

Also, with WAMP, where do I put my php files?

Ray Titus

In PHPMyAdmin’s application folder, you’ll find a file called config,inc.php which contains the values that PHPMyAdmin is using to try to connect to MySQL. You need to change the values for user and password to match the values your’re using to access MySQL via the command line. As you’re using WAMP you’ll probably find that PHPMyAdmin’s application folder can be found at:

C:\wamp\apps

Thanks, but I’ve looked at that file, edited it, all with no change in results. Since I had changed the MySQL root password via the MySQL Command line prompt, I changed the password in the config.inc.php file to match the change. That didn’t work, so I deleted the root password. So, as of right now, the root login for MySQL has NO password. My phpMyAdmin config.inc.php is as follows:
<?php

/* Servers configuration */
$i = 0;

/* Server: localhost [1] */
$i++;
$cfg[‘Servers’][$i][‘verbose’] = ‘localhost’;
$cfg[‘Servers’][$i][‘host’] = ‘localhost’;
$cfg[‘Servers’][$i][‘port’] = ‘’;
$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’;
$cfg[‘Servers’][$i][‘password’] = ‘’;
$cfg[‘Servers’][$i][‘AllowNoPassword’] = true;

/* End of servers configuration */

$cfg[‘DefaultLang’] = ‘en-utf-8’;
$cfg[‘ServerDefault’] = 1;
$cfg[‘UploadDir’] = ‘’;
$cfg[‘SaveDir’] = ‘’;

?>
Running phpMyAdmin from the Wampserver tray menu, I still receive the message:
#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.

So you can see the config info, which is the default from the standard install. Addmittedly, I don’t need phpMyAdmin to work in order to do my development and testing, but it sure makes the job a lot easier.

Try running this script (substituting the username and password for the appropriate values).

<?php
$apache_version            = $_SERVER['SERVER_SOFTWARE'];
$php_version            = phpversion();
$link                    = mysqli_connect("localhost", "db_user_name", "db_password");
$mysql_server_version    = mysqli_get_server_info($link);

echo "
    <p>Apache (Version: $apache_version) is running the following versions of PHP and MySQL:</br>
    PHP: $php_version</br>
    MySQL: $mysql_server_version</p>
    ";
?>

If it runs ok, it will display the versions of server software, php and MySQL that are being used. A successful run of it would point to a problem with PHPMyAdmin, it it fails to display the version of MySQL being used then that would point to a problem with php’s set-up for connection to MySQL.

I’ll give that a try but I still have another question: where do I put the script in WAMP? I know that normally it goes in the htdocs directory, but I’ve tried that and I get a 404 error.

One thing I forgot to mention… I’ve tried placing the scripts in c:\wamp\www (the DocumentRoot directory) but still get a 404 error.

OK. I’ve got the scripts running (from C:\wamp\www) and the test script you provided listed the PHP version and SQL version.

But I still get a HTTP 404 error when trying to run phpMyAdmin.

When I did the individual installs following the sitepoint book, everything worked except phpMyAdmin, getting the same result. I only went to WAMP because I thought I had made a mistake doing the individual installs.

Ray Titus

I’m not sure what I did but phpMyAdmin is now working. The only thing I did since my last note was reboot my computer, since I thought I may have changed something. I’d like to figure out what happened, but for now I’m happy it’s working so I can get on with developing my application.

Thanks for your help; I’m certain something we tried corrected the issue.

Ray Titus