MySQL Access Denied: 'Access denied for user 'root@localhost' (using password:NO)'
When attempting to run WordPress locally, you may encounter an error stating "Access denied for user 'root@localhost' (using password:NO)." This occurs when the MySQL root user password has not been set.
Steps to Resolve the Password Issue:
Stop the MySQL Service:
Start MySQL without Privileges:
Run the following command:
mysqld_safe --skip-grant-tables &
Enter MySQL Shell:
In a new terminal window, run:
mysql -u root
Clear and Grant Privileges:
Use the following commands to clear the user table and grant root privileges:
USE mysql; TRUNCATE TABLE user; FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'YourNewPassword' WITH GRANT OPTION;
Confirm Changes and Restart MySQL:
Additional Notes:
The above is the detailed content of How to Fix 'Access denied for user 'root@localhost' (using password:NO)' in Local WordPress MySQL?. For more information, please follow other related articles on the PHP Chinese website!