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. 前端知识之HTML标签

    1.HTML是一个标准,规定了大家怎么写网页. 2.HTML->>学标签 <标签名>    -->  标记语言(HTML.XML) 3.标签分类 双标签.单标签 (1)& ...

  2. Java(6)集合

    一.Java集合框架概述 1.什么是集合 集合框架:用于存储数据的容器. 数组.集合等存储数据的结构,叫Java容器. 此时的存储,是指内存层面的存储,不涉及持久化的存储. 任何集合框架都包含三大块的 ...

  3. 鸿蒙系统freeModbusTcp移植简介

    freeModebus是工业中常用的一种通信, 在鸿蒙系统来移植 细节查看代码中,博文只是一些参考以及注意点, 参考了 wifi连接: https://harmonyos.51cto.com/post ...

  4. vue路由参数的获取、添加和替换

    获取路由参数 getUrlKey(name){//获取url 参数 return decodeURIComponent((new RegExp('[?|&]'+name+'='+'([^&am ...

  5. PHP获取数组中重复值的键值

    $array = array ( 0=>'a', 1=>'b', 2=>'a', 5=>'b', 6=>'c', 40=>'d' ); $keyarr =[];$r ...

  6. Spring Boot第一天

    1.首先在idea中创建一个maven项目,创建成功后在pom.xml中添加SpringBoot相关的依赖 <!--引入SpringBoot相关的依赖--> <parent> ...

  7. mybatis 动态SQL 源码解析

    摘要 mybatis是个人最新喜欢的半自动ORM框架,它实现了SQL和业务逻辑的完美分割,今天我们来讨论一个问题,mybatis 是如何动态生成SQL SqlSessionManager sqlSes ...

  8. LeetCode 047 Permutations II

    题目要求:Permutations II Given a collection of numbers that might contain duplicates, return all possibl ...

  9. FPGA 串口

    VerilogHDL那些事儿_建模篇(黑金FPGA开发板配套教程) 作者:akuei2 说明:参照该书将部分程序验证学习一遍 学习时间:2014年5月3号 主要收获: 1. 对串口有初步了解: 2. ...

  10. rest-framework 解析器

    一 解析器的作用: 根据请求头 content-type 选择对应的解析器对请求体内容进行处理. 有application/json,x-www-form-urlencoded,form-data等格 ...