Home » Php » php – xampp localhost phpmyadmin Access denied for user 'root'@'localhost' (using password: YES)

php – xampp localhost phpmyadmin Access denied for user 'root'@'localhost' (using password: YES)

Posted by: admin July 12, 2020 Leave a comment


I am getting two errors when I try to go to my phpmyadmin localhost

Access denied for user 'root'@'localhost' (using password: YES)

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.

I don’t know what I am doing wrong…here is my config code…

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

 * Servers configuration
$i = 0;

 * First server
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'password';
$cfg['Servers'][$i]['connect_type'] = 'socket'; 
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['AllowNoPassword'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysql';
/* User for advanced features */
//$cfg['Servers'][$i]['controluser'] = 'pmauser';
//$cfg['Servers'][$i]['controlpass'] = 'pmapass';
/* Advanced phpMyAdmin features */
//$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
//$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
//$cfg['Servers'][$i]['relation'] = 'pma_relation';
//$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
//$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
//$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
//$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
//$cfg['Servers'][$i]['history'] = 'pma_history';

 * End of servers configuration

 * Directories for saving/loading files from server
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';


I notice a lot of code is commented out, should I un-commented it?

How to&Answers:

Don’t change anything , put as it was there , just open your xampp and try to access mysql from shell cd c://xampp/mysql/bin after this write
and click enter it will open your databases


try these step

  1. Open config.inc.php file in the phpmyadmin directory

  2. Find line 21: $cfg['Servers'][$i]['password'] = ''

  3. Change it to: $cfg['Servers'][$i]['password'] = 'your_password';

  4. Restart XAMPP

here is full description with image


After spending so much time what i came know is.

Just use this setting-> Open config.inc.php file in the phpmyadmin directory

/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true;  
$cfg['Lang'] = '';

You should have one user with @localhost host name. Now phpmyadmin will ask you for password. if you provide correct password,You will be able to login.


Change the following line under your config code from

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


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


Try to login to the database from command line using the same authentication credentials. This way you verify that you are really using the correct authentication credentials like username and password. If you fail on command line the problem is not with phpmyadmin but with your database engine setup.


If the XAMPP->MySQL Port was changed, (default port is 3306) the new port must be added to the phpMyAdmin file:

xampp phpmyadmin access denied error(#2002)


$cfg['Servers'][$i]['host'] = '';
to :
$cfg['Servers'][$i]['host'] = '';