mysql 5.7 You must reset your password using ALTER USER statement before executing this statement.

问题现象:

mysql 5.7.44 环境里    已经初始化数据库完成,通过初始化密码 mysql -uroot -p 登录,但是在执行sql时报错 :ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

处理办法:

1、执行set password=password(root,'需要设定的密码');

2、设定密码不过期: alter user 'root'@'localhost' password expire never;

3、执行 flush privileges;刷新 

步骤如下图所示

mysql 5.7 You must reset your password using ALTER USER statement before executing this statement._第1张图片

重启mysql 服务:service mysqld restart 

然后 再去使用sql 查询就可以了:

mysql 5.7 You must reset your password using ALTER USER statement before executing this statement._第2张图片

你可能感兴趣的:(数据库,mysql,数据库)