mysql 8.0忘记root密码
2024-09-03 10:33:04
1、修改参数文件添加以下内容
skip-grant-tables 2、关闭数据库
[root@node01 ~]# /etc/init.d/mysqld8 stop
Shutting down MySQL. SUCCESS! 3、重启数据库
[root@node01 ~]# /etc/init.d/mysqld8 start
Starting MySQL.. SUCCESS! 4、修改用户密码为空
mysql> update mysql.user set authentication_string='' where user='root' and host='localhost';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec) 5、关闭数据库
[root@node01 ~]# /etc/init.d/mysqld8 stop
Shutting down MySQL. SUCCESS! 6、去掉参数文件中以下内容
skip-grant-tables 7、启动数据库
[root@node01 ~]# /etc/init.d/mysqld8 start
Starting MySQL.. SUCCESS! 8、使用空密码登录数据库
[root@node01 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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> 9、修改用户密码
mysql> alter user 'root'@'localhost' identified by 'mysql';
Query OK, 0 rows affected (0.00 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) 10、使用新密码登录数据库
[root@node01 ~]# mysql -uroot -pmysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.22 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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>
最新文章
- shell 中的与、或表达式
- JAVA新手笔记 Intent对象和Bundle对象
- Liferay 6.2 改造系列之十:修改系统登录相关配置
- 为什么不能把委托(delegate)放在一个接口(interface)当中?
- oracle视图如何使用
- HDU 1856
- [转载] ubuntu下定制Vim/Gvim及使用技巧
- 关于iOS自定义返回按钮右滑返回手势失效的解决:
- Javaweb入门20160301 ---xml入门
- css控制图片变灰色,彩色
- nginx_http核心模块(二)
- java 文件字符输入、输出流
- poj 2455 二分+最大流
- tp5无法隐藏index.php入口文件
- 笔记:Hibernate 查询缓存
- java 线程方法 ---- join()
- 京东618:Docker扛大旗,弹性伸缩成重点 (2015-06-23)
- python六十八课——网络编程之UDP协议
- Spring Boot 2 (十):Spring Boot 中的响应式编程和 WebFlux 入门
- VBA二次学习笔记(3)——批量合并单元格