mysql修改密码1820_mysql密码丢失 ERROR 1820 (HY000): You must SET PASSWORD before executing this statement...

密码丢失修改密码

mysql> use mysql

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> exit

Bye

[root@localhost ~]# /etc/init.d/mysql stop

ERROR! MySQL server process #17602 is not running!

[root@localhost ~]# ps -ef|grep mysql

root 18980 15786 0 21:11 pts/3 00:00:00 grep mysql

下面是修改步骤

[root@localhost ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[1] 19128

[root@localhost ~]# 150610 21:11:39 mysqld_safe Logging to '/var/lib/mysql/localhost.localdomain.err'.

150610 21:11:39 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

mysql -u root mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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.

mysql> UPDATE user SET Password=PASSWORD('broadtech') where USER='root';

Query OK, 0 rows affected (0.00 sec)

Rows matched: 4 Changed: 0 Warnings: 0

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Bye

[root@localhost ~]# /etc/init.d/mysql restart

Shutting down MySQL..150610 21:12:36 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended

SUCCESS!

Starting MySQL. SUCCESS!

[1]+ Done mysqld_safe --user=mysql --skip-grant-tables --skip-networking

[root@localhost ~]#

You have new mail in /var/spool/mail/root

[root@localhost ~]#

[root@localhost ~]# ps -ef |grep mysql

root 19496 1 0 21:12 pts/3 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid

mysql 19597 19496 2 21:12 pts/3 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-file=/var/lib/mysql/localhost.localdomain.pid

root 19627 15786 0 21:12 pts/3 00:00:00 grep mysql

最后修改完成

[root@localhost ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.24

Copyright (c) 2000, 2015, 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.

mysql>

但是登陆后,执行还是会报错

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement,必须重新设置一次密码:

[root@localhost ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 35

Server version: 5.6.24

Copyright (c) 2000, 2015, 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.

mysql> use mysql

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> SET PASSWORD = PASSWORD('broadtech');

Query OK, 0 rows affected (0.00 sec)

mysql> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql>

在你用客户端登陆时,会报密码过期, 所以需要再改一次密码

官网说:

It is possible to “reset” a password by setting it to its current value. As a matter of good policy, it is preferable to choose a different password.

所以改为123456

mysql> SET PASSWORD = PASSWORD('123456');

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当你在安装MySQL 8.0之后执行相关语句时,如果出现"ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement."的错误,你需要通过ALTER USER语句重置你的密码才能执行该语句。解决这个问题有几种方法可以尝试使用: 方法一: 1. 打开MySQL命令行工具,并输入以下命令: ALTER USER USER() IDENTIFIED BY 'your_password'; 这将重置你的密码为你指定的"your_password"。 方法二: 1. 修改root密码。可以使用以下步骤: a. 打开MySQL命令行工具,并输入以下命令: SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your_password'); 这将修改root用户的密码为你指定的"your_password"。 b. 重新登录MySQL并使用新密码进行验证。 方法三: 1. 使用以下语句修改密码SET PASSWORD = 'your_password'; 你需要将"your_password"替换为你想要设置的密码。 2. 如果你的密码符合MySQL的要求,那么修改密码会成功。如果出现"ERROR 1819 (HY000): Your password does not satisfy the current policy requirements"的错误信息,则需要执行以下两条语句: SET GLOBAL validate_password.policy=0; SET GLOBAL validate_password.length=1; 然后再次执行步骤1中的语句即可。 希望以上方法能够帮助你解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [【已解决】【Mysql8.0】ERROR 1820 (HY000): You must reset your password using ALTER USER statement](https://blog.csdn.net/wingrez/article/details/99825144)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [分享MySql8.0.19 安装采坑记录](https://download.csdn.net/download/weixin_38703794/13683419)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值