Mysql access denied error for user root@localhost in XAMPP

Problem: Mysql access denied error for user root@localhost when using in XAMPP server (windows) even when credentials are correct.

Solution: Actually the problem is not in code, the issue is that by-default mysql in xampp allowed passwordless authentication in mysql, so we have to disable that and it will work as normal.
Go to XAMPP control panel then open and edit my.ini (mysql config file):

You have to uncomment a statement in below section:

Note: Before uncomment, set the mysql root password from phpmyadmin user setting option:

Line 19 # password = your_password

Uncomment Line 19,
save file and restart mysql service.

And edit config.inc.php file in the phpmyadmin directory:

And replace the below line:

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

To this:

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

“your_password” can be anything you like.

One comment

  1. Thanks for sharing useful information!! I am really impressed to see that you have provided such an interesting information about phpMyAdmin error.
    I was struggling with the same issue since last 3 days and finally solved it. Anyways can you suggest me some better option to get cheap linux hosting other than redserverhost.com?
    Thank you once again!!

Leave a Reply

Your email address will not be published. Required fields are marked *