Home  >  Article  >  Database  >  How to Fix the \"Access Denied\" Error in MySQL with WAMP?

How to Fix the \"Access Denied\" Error in MySQL with WAMP?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-26 15:05:02326browse

How to Fix the

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:

  1. Change the Root Password:

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';
  1. Update Configuration File:

Edit the config.inc.php file and change the root password to 'MyNewPass':

$cfg['Servers'][$i]['password'] = 'MyNewPass'
  1. Restart MySQL Service:

Stop and re-start the MySQL service using the following commands (assuming you're running WAMP on Windows):

mysql_stop.bat
mysql_start.bat
  1. Reconnect:

Try connecting to MySQL or phpMyAdmin again using the new password. You should now be able to access MySQL successfully.

Additional Tips:

  • Ensure that your firewall is not blocking the MySQL port (3306 by default).
  • Verify that the MySQL user 'root' has the necessary privileges to access the database.
  • Check for any SELinux or AppArmor restrictions that may be preventing access.
  • If you're using MySQL version 5.7 or later, use 'authentication_string' instead of 'Password' in the update statement.

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn