码迷,mamicode.com
首页 > 数据库 > 详细

Centos登录Mysql时忘记密码

时间:2020-02-03 14:00:58      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:bsp   warning   启动mysql   改密码   database   upd   stop   http   connect   

 Centos登录Mysql时忘记密码解决办法:

  1.停止Mysql服务(在mysql目录下)

    ./support-files/mysql.server stop

  2.修改配置文件/etc/my.cnf

            在[mysqld]下添加skip-grant-tables

            意思是忽略密码

            保存并退出

  3.启动Mysql(在Mysql目录下)

    /support-files/mysql.server start

  4.修改密码

 
            Welcome to the MySQL monitor. Commands end with ; or \g.
            Your MySQL connection id is 3 to server version: 3.23.56
            Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.
            mysql> USE mysql ;
            Database changed
            mysql> UPDATE user SET Password = password ( ‘新的密码) WHERE User = ‘root‘ ;
            Query OK, 0 rows affected (0.00 sec)
            Rows matched: 2 Changed: 0 Warnings: 0
            mysql> flush privileges ;
            Query OK, 0 rows affected (0.01 sec)
            mysql> quit
  5.改回配置,重启服务(在Mysql目录下)
    /support-files/mysql.server start
    
————————————————
版权声明:本文为CSDN博主「小楼看风云」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/linux_s2018/article/details/80762820

Centos登录Mysql时忘记密码

标签:bsp   warning   启动mysql   改密码   database   upd   stop   http   connect   

原文地址:https://www.cnblogs.com/qianmo123/p/12255312.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!