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.

  1. Close the mysql service
    sudo /usr/local/mysql/support-files/mysql.server stop or there is a MySQL shutdown in the system preferences
  2. Go to the mysql directory
    cd /usr/local/mysql/bin
  3. Get permission
    sudo su
  4. Restart the mysql service
    ./mysqld_safe –skip-grant-tables & or enable in system number
  5. Reopen the terminal
    mysql -uroot -p (you can just enter it when prompted for a password
  6. Get permission (you can change the password)
    flush privileges;
  7. Change password
    set password for ‘root’@’localhost’=password(‘new password’);

set password for ‘root’@’localhost’=password(‘new password’);

Leave a Reply

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

en_USEnglish