Getting error message about password for WAMP

Just successfully downloaded WAMP server. Tried to open a php file in localhost. Got this error, what should I do:

Warning: mysqli::mysqli(): (HY000/1045): Access denied for user ‘root’@‘localhost’ (using password: YES) in C:\wamp\www\config.php on line 6
Call Stack

# Time Memory Function Location
1 0.1770 167728 {main}( ) ..\\login.php:0
2 0.4430 173456 require_once( 'C:\\wamp\\www\\config.php' ) ..\\login.php:3
3 0.4670 174600 mysqli ( ) ..\\config.php:6
Connect Error (1045)Access denied for user 'root'@'localhost' (using password: YES)

I think you need to configure the password of your wamp server. try the instructions here: http://www.phpmytutor.com/blogs/2012/08/27/change-mysql-root-password-in-wamp-server/

I have a newer version of WAMP, just downloaded 4.0.4 but your link describes 3.5.1 - so the files don’t match what it describes (I had already tried that link in the past). Any other thoughts?

Check that the database user that your php script is using to access MySQL, firstly that the user exists and then that it has permission to access whichever database it’s trying to access

Below is a copy of the config.php file, for example. I should change DBUSERNAME? Having a challenge putting the pieces together of how to get this done.

<?php
define(‘DBHOSTNAME’,‘localhost’);
define(‘DBUSERNAME’,‘root’);
define(‘DBPASSWORD’,‘root’);
define(‘DBNAME’,‘yourname’);

Can you post the php code that’s failing, specifically the part where you connect to the database?

Here’s a file that fails (config.php):

<?php
define(‘DBHOSTNAME’,‘localhost’);
define(‘DBUSERNAME’,‘root’);
define(‘DBPASSWORD’,‘root’);
define(‘DBNAME’,‘yourname’);

And here’s the error message I receive when I try to open it in localhost:

arning: mysqli::mysqli(): (HY000/1045): Access denied for user ‘root’@‘localhost’ (using password: YES) in C:\wamp\www\config.php on line 6
Call Stack

# Time Memory Function Location
1 0.1770 167728 {main}( ) ..\\login.php:0
2 0.4430 173456 require_once( 'C:\\wamp\\www\\config.php' ) ..\\login.php:3
3 0.4670 174600 mysqli ( ) ..\\config.php:6
Connect Error (1045)Access denied for user 'root'@'localhost' (using password: YES)

Fire up PHPMyAdmin and click on the “Users” tab, is there a user listed there called “root”?

PHPMyAdmin has a list across the top of the page: Databasaes, SQL, Status, Export, Import, Settings, Variables, Charsets, Engines.

I don’t see a “Users” tab…

It might be listed as “Privileges” instead. What is the version number of PHP that you’re using?

It’s a WAMP version: phpmyadmin version 4.0.4

Don’t see “privileges”…

I’ve just downloaded that version and it shows “Users”, can you post a screenshot of what you see (remember to blank out any passwords that are visible)?

Just fiddled with it and realized when logging into phpMyAdmin it defaulted to “mysql default db” username, but now I chose “root” username and found “Users” like you said.

I see three users called “root” with the choices of “host” I’ll list below:

127.0.0.1
::1
localhost

Alongside each of those, what does it say in the password column, Yes or No? My default WAMP installation (though quite a bit older than yours) defaulted to no password which I have left for testing, but you’re specifying a password in that file. I wondered if it’s something simple like having it configured to use a password, but not having a password set for root?

It says No for all of them. How to correctly configure for a password then?

On mine, you just click the ‘edit’ button on the far right hand end of the row for the user you want to edit, then one of the fields is to select either ‘no password’, or to enter a password for the account.

Problem here is you’re specifying a password, but the account is not set up for one, so you fail authentication.