一;配置免密登录

找到mysql的my.cnf配置文件
在mysqld组加上一行skip-grant-tables

二;重启mysqld使其配置生效

执行systemctl restart mysqld

三;进入mysql清空旧密码

mysql -u root -p //提示输入密码时直接敲回车。
use mysql //选择数据库
update user set authentication_string = ‘’ where user = ‘root’; //将密码置空
quit //退出

[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.26 MySQL Community Server - GPLCopyright (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>
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 = '' where user = 'root';
Query OK, 1 row affected (0.00 sec)
mysql> quit
Bye

四;取消my.cnf免密登录并重启mysqld使其配置生效

执行systemctl restart mysqld

五;修改密码

mysql -u root -p //提示输入密码时直接敲回车,刚刚已经将密码置空了
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘abc123@xxx’;//'abc123@xxx’
密码形式过于简单则会报错

[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.26 MySQL Community Server - GPLCopyright (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>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Linux@112';
Query OK, 0 rows affected (0.00 sec)
mysql> quit

linux下mysql 8.0密码忘了怎么办相关推荐

  1. linux下mysql的root密码忘记解决方

    linux下mysql的root密码忘记解决方 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没 ...

  2. linux下mysql 8.0忘记密码后重置密码

    设置免密码登陆 编辑mysql配置文件my.cnf 在最后添加skip-grant-tables 保存 重启mysql服务: service mysqld restart: 免密登录MySQL将旧密码 ...

  3. linux下mysql的root密码忘记解决方案

    参考:http://www.cnblogs.com/allenblogs/archive/2010/08/12/1798247.html 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接M ...

  4. ***linux下mysql的root密码忘记解决方法

    1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库.  因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的  状态下,其他的用户也可以任意地 ...

  5. linux下mysql修改root密码

    方法一:用set password命令 首先,登陆mysql mysql -u root -p 然后执行set password命令 set password for root@localhost = ...

  6. linux下mysql的root密码忘记解决方法

    1.首先确认服务器出于安全的状态,最安全的状态是到服务器的Console上面操作,并且拔掉网线,或者可以使用--skip-networking限制只能从本地连接 2.修改MySQL的登录设置: # v ...

  7. Linux下MySQL 8.0 修改密码

    1.修改配置文件 vim /etc/my.conf 在[mysqld] 下面新增一行 skip-grant-tables 按键盘的ESC键(退出输入模式)再按键盘的" : " + ...

  8. 【教程】Linux下MySQL 8.0安装配置

    1.编译安装MySQL8.0 版本信息 #cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) 安装依赖包 yum -y insta ...

  9. Linux下MySQL忘记root密码及解决办法

    第一步 修改MySQL的配置文件(默认为/etc/my.cnf),在配置文件的[mysqld]标签下加入一行"skip-grant-tables",并保存文件 sudo vim / ...

最新文章

  1. php学数据结构,PHP 程序员学数据结构与算法之《栈》
  2. 一個简单的okhttp访问网络的例子
  3. win10+VS2013+opencv2.4.11的安装和配置
  4. BERT源码分析(PART II)
  5. 【HDU - 2030 】汉字统计 (C语言汉字编码,长知识)
  6. 扫描线三巨头 hdu1928hdu 1255 hdu 1542 [POJ 1151]
  7. MongoDB 日志文件过大的解决方法
  8. Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?
  9. c# 整个工程(包括窗体工程)做成dll
  10. php mixed约束,Mixed Content: 混合被动/显示内容和混合活动内容
  11. SQL语句关于数据库安全性
  12. 利用算法识别车厘子与樱桃
  13. paip.数组以及集合的操作uapi java php python总结..
  14. 【编程软件】keli烧录代码点击Download或者Debug界面卡死
  15. ikm java_ikm(IKM在线)
  16. ae运动模糊插件安装教程_AEPR运动模糊插件(RSMB) REVisionFX ReelSmart Motion Blur Pro v4.2.3...
  17. Python微信公众号接入图灵机器人
  18. iOS 实用方法创建单利+宏定义创建单利
  19. Oracle用户被锁定问题
  20. 凯利讯半导体滤波器的种类与作用

热门文章

  1. java多线程学习之【Exchanger】
  2. Vue全家桶学习笔记_零基础入门到入坑:Vue篇
  3. “土法”排查与修复一个 Linux 内核 Bug
  4. 鸿蒙系统 p40 尺寸,P40尺寸
  5. (附源码)基于PHP MYSQL开发的化妆品店会员管理网站的设计与实现 毕业设计131102
  6. JAVASE基础 Item -- 多线程,并发
  7. 蒙特卡洛模拟预测公司未来的毛利润
  8. 互联网自媒体平台大全,你知道多少?
  9. 使用基于分形系统的离线签名方法
  10. 字符串的编辑距离计算