MySQL-安装mysql后第一次登入或者重新登入mysql提示 reset your password的处理方法

基础环境

操作系统:window7

MySQL版本:5.7.26


第一次安装之后,按照默认密码,登入MySQL

D:\MySQL\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.26

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

无论输入什么,都提示reset your password

mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement befo
re executing this statement.
mysql> CREATE DATABASE test;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement befo
re executing this statement.

解决方法-重置user密码(两个方法都可用)

方法一

set password=password("root");#表示设置密码为root

flush privileges;#更新权限

mysql> set password=password("root");
Query OK, 0 rows affected, 1 warning (0.35 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.23 sec)

方法二 

alter user user() identified by "123456"; #表示设置密码为123456

mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.04 sec)

查看mysql的版本信息

mysql> select version()
    -> ;
+-----------+
| version() |
+-----------+
| 5.7.26    |
+-----------+
1 row in set (0.00 sec)

查看mysql密码生命周期

mysql> show variables like 'default_password_lifetime';
+---------------------------+-------+
| Variable_name             | Value |
+---------------------------+-------+
| default_password_lifetime | 0     |
+---------------------------+-------+
1 row in set, 1 warning (2.64 sec)

 

参考资料:【mysql】You must reset your password using ALTER USER statement before executing this statement. - 程序猿开发日志【学习永无止境】 - CSDN博客 https://blog.csdn.net/hj7jay/article/details/65626766

参考资料:MySQL 输入任何语句都提示You must reset your password using ALTER USER 解决方法 - xie_sining的博客 - CSDN博客 https://blog.csdn.net/xie_sining/article/details/80452670

 

你可能感兴趣的:(MySQL-安装mysql后第一次登入或者重新登入mysql提示 reset your password的处理方法)