侧边栏壁纸
博主头像
牧之

道阻且长、行则将至

  • 累计撰写 49 篇文章
  • 累计创建 32 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

CentOS 7 MySQL密码重置

牧之
2021-07-24 / 0 评论 / 0 点赞 / 52 阅读 / 208 字
温馨提示:
本文最后更新于 2022-06-03,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

修改 MySQL 配置文件以跳过密码登录

# vim /etc/my.cnf 

添加skip-grant-tables;

98204-dhf64l3raec.png

重启 MySQL 服务

# systemctl restart mysqld.service

登录修改

[root@cvm-3ibcdh728a225 html]# mysql -u root 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34 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> 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> update user set authentication_string='your-new-passwd' where user='root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

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

mysql> quit
Bye

将设置文件改回

# vim /etc/my.cnf 

重启 MySQL

# systemctl restart mysqld.service

修改完成。

0

评论区