mysql忘记密码的时候重置密码

1.在/etc/my.cnf中添加配置 免密码登陆

复制代码
skip-grant-tables

2.进行免密码登陆(mysql指令位于mysql安装目录的bin/)

复制代码
mysql -u root 

3.重置密码

sql 复制代码
use mysql;
update mysql.user set authentication_string=password('root_password') where user='root'; 
flush privileges;
exit;
  1. 在/etc/my.cnf 中去掉免密码登录的配置
sql 复制代码
#skip-grant-tables
  1. 启动mysql服务
sql 复制代码
service mysql restart
相关推荐
RisunJan21 小时前
Linux命令-help命令(查看 Shell 内置命令帮助信息)
linux·运维·服务器
倔强的石头_21 小时前
性能飙升!KingbaseES V9R2C13 Windows安装与优化特性深度实测
数据库
梦里不知身是客1121 小时前
Doris 中主键模型的读时合并模式
数据库·sql·linq
GanGuaGua21 小时前
MySQL:复合查询
数据库·mysql·oracle
gugugu.21 小时前
MySQL事务深度解析:从ACID到MVCC的实现原理
数据库·mysql·oracle
大猫和小黄21 小时前
Windows环境下在VMware中安装和配置CentOS 7
linux·windows·centos
DechinPhy21 小时前
使用Python免费合并PDF文件
开发语言·数据库·python·mysql·pdf
共享家952721 小时前
MySQL-基础查询(下)
android·mysql
梁正雄21 小时前
linux服务-Kibana8原理与安装
linux·运维·服务器
苹果醋31 天前
JAVA设计模式之策略模式
java·运维·spring boot·mysql·nginx