zoukankan      html  css  js  c++  java
  • MySQL数据库应用(4)管理实战(2)-- 找回密码

    八、找回丢失的mysql root用户密码

        1、启动修改丢失的MySQL单实例root密码方法

            1)首先停止mysql

    [root@localhost ~]# /etc/init.d/mysqld stop
    Shutting down MySQL. SUCCESS! 

            2)使用--skip-grant-tables启动mysql,忽略授权登录验证

    [root@localhost ~]# mysqld_safe --skip-grant-tables --user=mysql &
    [1] 1866
    [root@localhost ~]# 190919 01:16:35 mysqld_safe Logging to '/application/mysql-5.5.32/data/localhost.localdomain.err'.
    190919 01:16:35 mysqld_safe Starting mysqld daemon with databases from /application/mysql-5.5.32/data
    
    [root@localhost ~]# mysql     < == 登录时空密码

            3)修改root密码为新密码

    mysql> update mysql.user set password=password('dubin') where user='root' and host='localhost';
    Query OK, 1 row affected (0.13 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    mysql> quit
    Bye

            4)重启服务器再登录

    [root@localhost ~]# /etc/init.d/mysqld stop
    Shutting down MySQL.190919 01:20:07 mysqld_safe mysqld from pid file /application/mysql-5.5.32/data/localhost.localdomain.pid ended
     SUCCESS! 
    [1]+  Done                    mysqld_safe --skip-grant-tables --user=mysql
    [root@localhost ~]# /etc/init.d/mysqld start
    Starting MySQL.. SUCCESS! 
    [root@localhost ~]# mysql -uroot -pdubin
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 1
    Server version: 5.5.32 Source distribution
    
    
    
    ##这里应该是不能用stop停止的,可能是我用set设置密码的原因
    应该是用mysqladmin停止服务

         2、多实例MySQL启动修改丢失root密码

            1)关闭mysql

    [root@localhost ~]# kill mysqld

            2)启动时加 --skip-grant-tables参数

            

            3)修改密码的方法

                               

             4)重启服务用新密码登录

                                  

       

  • 相关阅读:
    函数参数传递
    C# 串口发送 陷阱,必须知道的坑
    Altera Quartus 13.1 仿真工具路径错误问题解决 Can't launch the ModelSim-Altera software
    Altium Designer 快速修改板子形状为Keep-out layer大小
    Altium Designer 敷铜间距设置,真实有效
    VS2012,VS2013启用SQLite的Data Provider界面显示
    Sqlite 设置外键级联更新
    Sqlite 设置默认时间为本地时间
    FPGA学习笔记之Altera FPGA使用JIC文件配置固化教程(转)
    FPGA学习记录
  • 原文地址:https://www.cnblogs.com/cnxy168/p/11570486.html
Copyright © 2011-2022 走看看