Home >Database >Mysql Tutorial >How to Fix the \'Access Denied\' Error in MySQL with WAMP?
Troubleshooting "Access Denied" Error in MySQL with WAMP
When attempting to connect to MySQL via the console or phpMyAdmin, the error message "#1045 - Access denied for user 'root'@'localhost' (using password: YES)" indicates an incorrect password or authentication issue. This issue arises despite ensuring that the correct password is used, likely due to a password discrepancy or other misconfiguration.
Solution:
To resolve this error, follow these steps:
Start the MySQL service with the following command:
mysql -u root -p
Inside the MySQL console, enter the following commands to update the root password:
UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
Edit the config.inc.php file and change the root password to 'MyNewPass':
$cfg['Servers'][$i]['password'] = 'MyNewPass'
Stop and re-start the MySQL service using the following commands (assuming you're running WAMP on Windows):
mysql_stop.bat mysql_start.bat
Try connecting to MySQL or phpMyAdmin again using the new password. You should now be able to access MySQL successfully.
Additional Tips:
The above is the detailed content of How to Fix the \'Access Denied\' Error in MySQL with WAMP?. For more information, please follow other related articles on the PHP Chinese website!