mysql重置密码linux,Mysql (Linux) 忘记密码,重置密码

1 关闭mysql 服务

systemctl stop mysqld

2 . 修改mysql 配置文件,跳过密码登录

echo skip-grant-tables >> /etc/my.cnf

3 . 开启mysql 服务,并登录mysql (不需要密码)

mysql

4 . 更改mysql系统中user表中登录用户的密码

--使用mysql 数据库

use mysql

--更新密码

--update user set password=password("要更改的密码") where user="更改的用户名";

--注意版本区别,在新版本中 提示没有这个password 字段,密码字段是authentication_string

--update user set authentication_string=password("要更改的密码") where user="更改的用户名";

update user set authentication_string=password("root") where user="root";

--刷新权限

flush privileges;

```[图片上传中...(dog.jpg-edd842-1533830145621-0)]

# 5 . 还原配置文件,并重启服务并登录

--将刚才修改的 mysql配置文件还原,删除最后一行,vi /etc/my.cnf

skip-grant-tables

--重启mysql 服务

systemctl restart mysqld

--使用新密码登录mysql

mysql -uroot -proot

# 6 . 修改密码完成 ,检查是否能够登录,并创建 库表

![dog.jpg](https://upload-images.jianshu.io/upload_images/13032930-8d86b5217d17b199.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值