数据库忘记密码

数据库忘记密码

5.7版本的数据库忘记密码解决办法

管理员密码忘记的处理

登录的时候显示如下报错

[root@db01 ~]# mysql -uroot -pasdfasdfasdf
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

(1)停数据库

[root@db01 ~]# /etc/init.d/mysqld stop

(2)“单用户”模式启动数据库

service mysqld start --skip-grant-tables --skip-networking 
或者:
mysqld_safe --skip-grant-tables --skip-networking &

( 3)登陆数据库改密码

mysql> alter user root@'localhost' identified by '123';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges ;
Query OK, 0 rows affected (0.01 sec)

mysql> alter user root@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)

(4)重启数据库到正常模式

[root@db01 ~]# service mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 

[root@db01 ~]# mysql -uroot -p123

8.0版本的数据库忘记密码解决办法

1 停数据库

systemctl stop mysqld

2 启动安全模式

mysqld_safe --skip-grant-tables  --skip-networking & 
mysql

3 改密码

flush privileges;  刷新授权表
alter user root@'localhost' indentified by '123456';

4 重启数据库到正常模式

/etc/init.d/mysqld restart
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值