0
点赞
收藏
分享

微信扫一扫

Mariadb root用户及普通用户的密码 重置

这里的密码指的是Mariadb的 root 用户的密码

root用户更改密码

如果记得root用户登入Mariadb的密码直接登入即可

/usr/local/mysql/bin/mysql -uroot -p123

如果不记得root密码:

1)编辑/etc/my.cnf
增加:skip-grant
重启服务
2)登录进MariaDB,执行
use mysql 切换到mysql库
desc user 查看user表的所有字段
update user set authentication_string=password("aming-linux") where user='root';
3)退出MariaDB,删除/etc/my.cnf里面的skip-grant, 重启服务
4)用新密码登录即可
1、编辑/etc/my.cnf

增加:skip-grant

/etc/init.d/mysqld restart 然后重启服务

image.png

2、直接登入Mariadb

/usr/local/mysql/bin/mysql -uroot 直接登入 不需要密码

进去之后

use mysq; 切换到MySQL数据库下
desc user; 查看user表的所有字段
update user set authentication_string=password("123456") where user='root'; 修改密码
3、退出MariaDB,删除/etc/my.cnf里面的skip-grant, 重启服务然后用新密码登入即可

image.png

普通用户更改密码
登入数据库之后 切换到mysql的库下
use mysql;
select user,host from user; 查看有哪些用户

image.png

修改密码与root一样 更改一下用户名称即可
比如修改bbs用户
例:
update user set authentication_string=password("123456") where user='bbs';

ps:

mysql在5.7.36版本之后把密码字段存到了authentication_string字段里,在之前版本存在password字段里。
update user set password=password("123456") where user='root';
如果是之前的版本,修改密码时 更改一下字段参数即可。
举报

相关推荐

0 条评论