mariadb root用户忘记密码

11 篇文章 0 订阅

1 root用户停止 mariadb 服务

[root@foundation65 ~]# systemctl stop mariadb.service 

在这里插入图片描述

2 跳过授权表

[root@foundation65 ~]# mysqld_safe --skip-grant-table &	# 跳过授权表
[1] 6201

3 直接输入mysql不用用户名和密码就可以进入mariadb了

[root@foundation65 ~]# mysql

在这里插入图片描述

4 更改root用户的密码为westos

MariaDB [(none)]> update mysql.user set Password=password('westos') where User='root';

5 杀死mysqld_safe --skip-grant-table进程

[root@foundation65 ~]# ps aux | grep mysql
root      6260  0.0  0.0 113252  1576 pts/1    T    17:17   0:00 /bin/sh /bin/mysqld_safe --skip-grant-table
mysql     6403  0.0  0.0      0     0 pts/1    Z    17:17   0:00 [mysqld] <defunct>
root      6532  0.0  0.0 112648   960 pts/1    S+   17:20   0:00 grep --color=auto mysql
[root@foundation65 ~]# kill -9 6260
[root@foundation65 ~]# ps aux | grep mysql
root      6534  0.0  0.0 112648   960 pts/1    S+   17:21   0:00 grep --color=auto mysql

6重新开启mariadb服务

[root@foundation65 ~]# systemctl start mariadb.service 

在这里插入图片描述

7用更改过的密码就可以重新登陆

直接输入 mysql已经不能直接进入了

[root@foundation65 ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@foundation65 ~]# mysql -uroot -pwestos

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值