MySQL数据库应用管理实战-- 找回密码

Posted 黯然亦销魂丶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL数据库应用管理实战-- 找回密码相关的知识,希望对你有一定的参考价值。

八、找回丢失的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)重启服务用新密码登录

                              

 

   

 

以上是关于MySQL数据库应用管理实战-- 找回密码的主要内容,如果未能解决你的问题,请参考以下文章

设置修改及找回 MySQL 数据库 root 用户的密码

mysql找回管理员密码

Express实战 - 应用案例- realworld-API - 路由设计 - mongoose - 数据验证 - 密码加密 - 登录接口 - 身份认证 - token - 增删改查API(代码片段

第三章 MySQL应用管理

SHOPEX管理员密码找回解决方法

mysql root 忘记密码