《MySQL系列-部署维护》MySQL8.0版本如何正确找回密码?

MySQL8.0找回密码

1.Windows服务器上部署有MySQL8.0服务,需要找回密码。但是按照常规的方法,在my.ini文件中添加skip-grant-tables参数,并重启MySQL并未生效

C:\Users\EDZ>mysql -uroot -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost:3306' (10061)

2.经过资料查找,采用如下方法:

尝试过mysqld --skip-grant-tables命令,但是依旧无法免密登录

mysqld --console --skip-grant-tables --shared-memory

D:\software\MySQL\mysql-8.0.27-winx64\bin>mysqld --console --skip-grant-tables --shared-memory
2023-03-28T09:00:39.296919Z 0 [Warning] [MY-000081] [Server] option 'wait_timeout': unsigned value 31536000 adjusted to 2147483.
2023-03-28T09:00:39.297172Z 0 [System] [MY-010116] [Server] D:\software\MySQL\mysql-8.0.27-winx64\bin\mysqld.exe (mysqld 8.0.27) starting as process 15764
2023-03-28T09:00:39.313331Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-03-28T09:00:39.715547Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-03-28T09:00:40.031200Z 0 [Warning] [MY-011311] [Server] Plugin mysqlx reported: 'All I/O interfaces are disabled, X Protocol won't be accessible'
2023-03-28T09:00:40.112717Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2023-03-28T09:00:40.112899Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2023-03-28T09:00:40.115167Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-03-28T09:00:40.115372Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-03-28T09:00:40.137087Z 0 [System] [MY-010931] [Server] D:\software\MySQL\mysql-8.0.27-winx64\bin\mysqld.exe: ready for connections. Version: '8.0.27'  socket: ''  port: 0  MySQL Community Server - GPL.

3.重启开启一个DOS窗口,已经可以免密登录。登陆后即可以关闭刚刚mysqld启动的DOS窗口。然后修改密码后,重新登陆即可

C:\Users\EDZ>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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> flush privileges;
Query OK, 0 rows affected (0.03 sec)


mysql> alter user 'root'@'localhost' identified by 'Zxy@123456';
Query OK, 0 rows affected (0.01 sec)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

DATA数据猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值