美文网首页
3. MySQL 重置密码命令

3. MySQL 重置密码命令

作者: chachacha88 | 来源:发表于2018-12-11 16:59 被阅读0次

    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';

    相关文章

      网友评论

          本文标题:3. MySQL 重置密码命令

          本文链接:https://www.haomeiwen.com/subject/tpmynftx.html