1. 准备
- 需要root权限
2. 解决方案
1.修改配置文件,添加跳过授权表的参数
vim /etc/my.cnf
2. 添加参数(跳过授权,直接登录)
[mysqld]
skip-grant-tables
3.用命令修改mysql的root密码(进入mysql)
use mysql;
update user set authentication_string=password("新密码") where host="localhost" and user="root";
4.刷新权限,立即生效
flush privileges;
5.打开配置文件,注释跳过授权表的参数
vim /etc/my.cnf
[mysqld]
#skip-grant-tables
6.重启服务端
systemctl restart mariadb