排障集锦:九九八十一难之第七难!mysql数据库登录密码忘记了
时间:2022-07-24
本文章向大家介绍排障集锦:九九八十一难之第七难!mysql数据库登录密码忘记了,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
Mysql5.7之后版本破解
vim /etc/my.cnf 进入到配置文件 skip-grant-tables 加上此字段 跳过密码直接登录 登录后对mysql库中的user表中authentication_string 密码字段进行更改
[root@localhost ~]# vim /etc/my.cnf '进入到配置文件'
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
skip-grant-tables '添加此行'
[root@localhost ~]# systemctl restart mysqld
[root@localhost ~]# mysql '再次登录发现不需要密码了'
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, 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> desc mysql.user; '查看密码字段'
authentication_string '此字段就是密码字段 当然这一步是在你记不住密码字段的情况下'
mysql> select user,host,authentication_string from mysql.user; '查看登录名 登录终端 密码'
+-----------+-----------+-------------------------------------------+
| user | host | authentication_string |
+-----------+-----------+-------------------------------------------+
| root | localhost | *7A8BBCB18A250055A6BB98ECFA33A8174D219504 |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| root | % | *6691484EA6B50DDDE1926A220DA01FA9E575C18A |
+-----------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)
mysql> update mysql.user set authentication_string=password('Abc123') where user='root' 'updata 跟新表内容 user表 当user为root的情况下 将其密码设置为Abc123'
-> ;
Query OK, 1 row affected, 1 warning (0.01 sec)
Rows matched: 2 Changed: 1 Warnings: 1
[root@localhost ~]# vim /etc/my.cnf
#skip-grant-tables '将刚才的字段进行注释'
[root@localhost ~]# systemctl restart mysqld '每次更改完文件都要进行重启服务'
[root@localhost ~]# mysql '再次登录发现需要验证密码了'
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost ~]# mysql -u root -p"Abc123" '用刚刚设置的密码再次尝试登录'
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 4
Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, 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>
Mysql5.7之前版本破解
vim /etc/my.cnf 进入到配置文件 skip-grant-tables 加上此字段 跳过授权表 登录后对mysql库中的user表中password 密码字段进行更改 只有密码字段不一样
[ root@mysql1 ~ ]# vim /etc/my.cnf
[mysqld]
skip-grant-tables
[root@mysql1 ~]# service mysqld restart
[root@mysql1 ~ ]# mysql
mysql> update mysql.user set passvord=password("456") where user="root" and host="localhost";
mysql> flush privileges; '刷新一下表'
mysql> q
[root@mysql1 ~]# vim /etc/my.cnf
[mysqld]
# skip-grant-table
[root@mysql1 ~]# service mysqld restart
- Spring集成RabbitMQ-必须知道的几个概念
- Spring读书笔记——bean创建(上)
- 15:21爆出的小程序功能升级,你还要对小程序观望吗?
- 如何解决分布式系统中的跨时区问题[原理篇]
- 什么是区块链:块的结构
- Spring读书笔记——bean创建(下)
- 当区块链遇上传统行业 我们的生活和工作会改变吗?
- 如何设计开发好一个 HTTP API?
- [WCF权限控制]基于Windows用户组的授权方式[下篇]
- Spring读书笔记——bean解析
- 10个大数据误区,看看你中了几个?
- 从数据到代码——通过代码生成机制实现强类型编程[上篇]
- Spring读书笔记——bean加载
- Java8-初识Lambda
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- SpringBoot2 整合FreeMarker模板,完成页面静态化处理
- PHP多文件上传格式化
- NDK开发案例 | C/C++调用java层代码
- 深入理解 SecurityConfigurer 【源码篇】
- Swift 属性
- Swift 类和结构体
- 使用深度学习和OpenCV的早期火灾检测系统
- 【时序预测】一文梳理时间序列预测——ARMA模型
- 三分钟Kubernetes-环境搭建篇
- Linux分区页框分配器之水位
- 使用GPU训练模型
- Spring事务源码分析专题(一)JdbcTemplate使用及源码分析
- TensorFlow处理运动想象分类任务
- 使用kepler.gl可视化地理空间数据
- 聊聊 Python 代码覆盖率工具 - Coverage