Resetting password to solve MySQL error ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
Open MySQL and report an error ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
Generally, this error is caused by a wrong password, and the solution is naturally to reset the password.
- Close the mysql service
sudo /usr/local/mysql/support-files/mysql.server stop or there is a MySQL shutdown in the system preferences - Go to the mysql directory
cd /usr/local/mysql/bin - Get permission
sudo su - Restart the mysql service
./mysqld_safe –skip-grant-tables & or enable in system number - Reopen the terminal
mysql -uroot -p (you can just enter it when prompted for a password - Get permission (you can change the password)
flush privileges; - Change password
set password for ‘root’@’localhost’=password(‘new password’);
set password for ‘root’@’localhost’=password(‘new password’);