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. dpkg 批量卸载

    dpkg -l |grep deepin|awk '{print $2}'|xargs sudo dpkg -P

  2. Elementary OS安装及开发环境配置(一)

    前言 假期在家无聊,刚好把六年前的一台笔记本电脑利用起来,原来电脑虽然说配置说不上古董机器,但是运行win系统感觉还是不流畅,所幸给换成Linux桌面版系统,在网上查阅了很多,Linux桌面系统要么推 ...

  3. webug第十四关:存储型XSS

    第十四关:存储型XSS 打开发现是评论区 留言加入xss语句

  4. Vegas实战——如何导入导出视频

    Vegas作为一款专业的视频非编软件,在国内受到了很多用户的喜爱.小编认为,对于很多用户来说,他们选择sony vegas的一个原因是vegas在不论是从产品性能,还是使用效果上,都很容易被用户接受. ...

  5. css3系列之详解box-shadow

    box-shadow box-shadow呢 是设置元素的阴影效果的,利用这个属性,可以设计很多很炫丽的效果,不信? 等下,学完,我们就来完成下面这两个效果 首先 先了解一下,box-shadow 的 ...

  6. appium元素定位总结

    appium元素定位方法总结 使用uiautomator定位 driver.find_element_by_android_uiautomator(uia_string) 根据resourceId属性 ...

  7. Linux 学习笔记01丨Ubuntu系统安装、配置及软件教程集合

    1. Ubuntu系统安装 Windows10安装ubuntu18.04双系统教程 Ubuntu 20.04.1 镜像下载 软碟通 机械革命进入BIOS模式 要按F2,注意将Boot Option中将 ...

  8. Django之ModelForm实际操作使用

    1.定义model数据库字段如下: class User(models.Model): """ 员工信息表用户.密码.职位.公司名(子.总公司).手机.最后一次登录时间. ...

  9. JUC详解--【Foam番茄】

    1.什么是JUC java.util 工具包 业务:普通的线程代码 Thread Runnable 没有返回值,效率相比于 Callable 相对较低! 2.线程和进程 进程:一个程序,QQ.exe ...

  10. Django的静态文件的配置

    静态文件配置 STATIC_URL = '/static/' # 静态文件配置 STATICFILES_DIRS = [ os.path.join(BASE_DIR,'static') ] # 暴露给 ...