3. MySQL 重置密码命令

1、首先停止mysql服务进程:

 service mysqld stop

2、然后编辑mysql的配置文件my.cnf

vim /etc/my.cnf

找到 [mysqld]这个模块:在最后面添加一段代码

skip-grant-tables  ##忽略mysql权限问题,直接登录

然后保存 :wq!退出

3、启动mysql服务:

service mysqld start

4、选择数据库

/usr/bin/mysql

use mysql;

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

 flush privileges; 

但是在5.7版本不存在password字段,所有我们要用以下修改进行重置密码

update user set authentication_string=password('123456') where user='root';

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容