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>

  

mysql 8.0忘记root密码的更多相关文章

  1. mysql 8.0 忘记root密码后重置

    最近状态很不好,一直晕晕晕晕晕晕乎乎的,一个测试实例,下班前修改了一下root的密码,接着就下班走人,第二天来发现root密码忘了 刚好自动化安装脚本整理好了,本来想着算了直接重装实例得了,简单省事也 ...

  2. MySQL 5.7忘记root密码如何修改?

    一直以来,MySQL的应用和学习环境都是MySQL 5.6和之前的版本,也没有去关注新版本MySQL 5.7的变化和新特性.今天帮人处理忘记root密码的时时候,发现以前的方法不奏效了.具体情况如下所 ...

  3. 修改mysql 8.0.16 root 密码--mac

    https://blog.csdn.net/HECTOR_1368391900/article/details/90732097 https://my.oschina.net/u/3251146/bl ...

  4. Centos7重置Mysql 8.0.1 root 密码

    问题产生背景: 安装完 最新版的 mysql8.0.1后忘记了密码,向重置root密码:找了网上好多资料都不尽相同,根据自己的问题总结如下: 第一步:修改配置文件免密码登录mysql vim /etc ...

  5. Mysql 5.7 忘记root密码或重置密码的详细方法

    在Centos中安装完MySQL数据库以后,不知道密码,这可怎么办,下面给大家说一下怎么重置密码 在Centos中安装完MySQL数据库以后,不知道密码,这可怎么办,下面给大家说一下怎么重置密码 1. ...

  6. mysql8.0 忘记root密码

    先打开一个cmd:net stop mysql //关闭mysql服务mysqld --shared-memory --skip-grant-tables//跳过登录密码在不关闭第一个CMD的情况下打 ...

  7. CentOS6.0忘记root密码解决办法

    说明操作系统:CentOS 6.0遇到问题:忘记管理员账号root的密码,进不了系统解决办法:重置root密码为123456操作: 开机启动系统,在进入系统之前按键盘上面的Esc键,会进入下面的界面 ...

  8. MySQL或MariaDB忘记root密码

    当我们忘记数据库密码时,我们可以通过如下来修改! 编辑配置文件(提前最好进行备份) 然后重启服务 systemctl restart mariadb 或者 systemctl restart mysq ...

  9. Linux下MySQL或MariaDB忘记root密码的解决方法

    1.vim /etc/my.cnf 2.在[mysqld]下添加一行skip-grant-tables,然后保存并退出. 3.重启mysql服务:service mysqld restart. 4.不 ...

随机推荐

  1. IDEA 使用的一些快捷键记录

    1,ctrl+tab 导航当前编辑打开的所有文件,按住Ctrl,使用backspace 可以关闭某个文件 2,ctrl+shift+alt+s 打开项目设置,alt+shift+s 打开所有设置 3, ...

  2. Java web 自动备份数据库和log4j日志

    利用监听自动备份 web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns: ...

  3. python-Requests模块的使用

    1. Requests简介 Requests模块是一个用于网络访问的模块,其实类似的模块有很多,比如urllib,urllib2,httplib,httplib2,他们基本都提供相似的功能,那为什么R ...

  4. pandas 生成html文档,支持可添加多个表

    如何通过pandas生成html格式?如何通过pandas生成html文件文件中包含多个表单Balance_64_data = pd.read_sql(Balance_64_sql,engine)df ...

  5. FL Studio中如何制作和混音Dutch Lead(上)

    Dutch Lead是电子音乐类型Dutch House以及Bigroom House中常用的Lead音色,这一篇文章中我将从制作和混音两方面来讲解Dutch Lead. (一).Dutch Lead ...

  6. 使用Camtasia 让照片变身动态视频

    视觉化影像已经慢慢渗入我们平日的生活了,很多人已经慢慢地从单纯的文字记录,发展到使用照片记录生活,而视频化的记录也随着智能手机的普及而迅速发展起来.对于一些曾经使用照片记录的瞬间,我们也可以将其变身为 ...

  7. mybatis中的一些标签使用

    主要有两个配置文件,一个是主配置文件SqlConfig.xml, 还有一个是dao接口实现类相对应的mapper的配置文件 .比如userDao的userDao.xml配置文件. 1.resultTy ...

  8. java中String类的使用

    一.Strng类的概念 String类在我们开发中经常使用,在jdk1.8版本之前(包括1.8),String类的底层是一个char类型的数组,1.8版本之后是byte类型的数组,正是因为String ...

  9. Win10定期执行python程序

    一:windows10自带的计划程序 第一步:在 计算器右击 --> 选择管理 进入如下界面: 第二步:选择 系统工具 -->  任务计划程序 ,点击右侧的  "创建基本任务&q ...

  10. LeetCode周赛#203 题解

    1561. 你可以获得的最大硬币数目 #贪心 题目链接 题意 有 3n 堆数目不一的硬币,你和你的朋友们打算按以下方式分硬币: 每一轮中,你将会选出 任意 3 堆硬币(不一定连续). Alice 将会 ...