You must reset your password using ALTER USER

On MySQL 8, when you start MySQL, it generate a temporary root password, that you can find with command

grep 'temporary password' /var/log/mysqld.log

When i try run some SQL commands after login with this temporary password, i get error

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

To fix this, you need to change your MySQL root password by running

ALTER USER 'root'@'localhost' IDENTIFIED  BY 'MYSQL_ROOT_PASSWORD';

MySQL 8 on CentOS Change MySQL Root Password

Need help with Linux Server or WordPress? We can help!

3 Comments

  • Wow.. It’s just need localhost.. so sad lah…
    I use it without localhost on MySQL 8.0.2 windows 64 bit. adding localhost as host on updateting the database solve the problem. Thank you
    This also work on windows 10

    • hi Benyamin,
      I use win 10. I installed mysql. It generated a temporary password for mysql root. Then I created a user with some permissions. yesterday the userlogin was working fine. Today it shows the error.

      C:\myWebProject\mysql\bin>mysql -u myuser -p
      Enter password: *****
      ERROR 1045 (28000): Access denied for user ‘myuser’@’localhost’ (using password: YES)

Leave a Reply

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