Problem symptoms:
In the mysql 5.7.44 environment, the database has been initialized and logged in through the initialization password mysql -uroot -p, but an error occurred when executing sql: ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Solution:
1. Executeset password=password(root,'Password to be set');
2. Set the password to not expire: alter user 'root'@'localhost' password expire never;
3、执行flush privileges;Renovation
The steps are as shown below
Restart mysql service:service mysqld restart
Then just use sql query: