Mysql access denied error for user root@localhost in XAMPP

Author - Navneet Kashyap

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.

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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