MySQL不知道密码,直接修改密码

很简单,我们跳过验证,直接进去修改就好

修改配置文件

shell 复制代码
vim /etc/my.cnf

[mysqld]下直接添加配置

shell 复制代码
skip-grant-tables

如图:

保存,退出即可。

重启服务

shell 复制代码
service mysqld restart

进入MySQL

shell 复制代码
#(直接点击回车,密码为空)
mysql -uroot -p 

选择数据库

shell 复制代码
use mysql

修改密码

shell 复制代码
update user set authentication_string=password('123456') where user='root';

刷新配置

shell 复制代码
flush privileges;

无脑合集

shell 复制代码
use mysql;
update user set authentication_string=password('123456') where user='root';
flush privileges;

至此,再次重启服务即可

shell 复制代码
service mysqld restart
相关推荐
甜可儿9 分钟前
redis序列化设置
数据库·redis
GGBondlctrl14 分钟前
【SpringBoot】论坛项目中如何进行实现发布文章,以及更新对应数据库的数据更新
数据库·springboot项目·三层设计思想·文章发布项目
若云止水28 分钟前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu
jay丿1 小时前
Django模板系统深入
数据库·django·sqlite
千层冷面1 小时前
Redis除了做缓存还能做什么?
数据库·redis·缓存
码有余悸3 小时前
Redis:高性能的键值存储系统
数据库·redis·缓存
剑客狼心7 小时前
Oracle:什么是存储过程
数据库·oracle
小王努力学编程7 小时前
【MySQL篇】表的操作
数据库·mysql
汤汤upup7 小时前
面试八股文--数据库基础知识总结(2) MySQL
数据库·mysql·面试
TangKenny7 小时前
information_schema.processlist 表详解
mysql·processlist