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)重启服务用新密码登录

                              

 

   

 

转载于:https://www.cnblogs.com/cnxy168/p/11570486.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值