0.中止mariadbhtml
systemctl stop mariadb.service #关闭mariadb
ps -ef | grep mariadb #查询进程PID
1.经过如下命令匿名登陆mariadbmysql
mysqld_safe --skip-grant-tables &
注意在这以后输入以下代码开启mysqlsql
mysql #后面不加任何用户名,直接登陆
2.匿名登陆后输入以下命令数据库
use mysql; #使用mysql系统数据库 insert into user(Host,User,Password) values('localhost','root',PASSWORD('123456')); #插入一个名为test的新用账号为test,密码为123,可根据自身须要自行修改 update user set Password=PASSWORD('123') where User='root' #将root密码改成123,做为重置root密码之用 select * from user; #查看用户是否加入
3.赋予建立用户全部权限bash
注意:此时若是如今使用赋权限语句ide
grant all privileges on *.* to test@localhost identified by '123456';
会报执行错误,由于用户以前经过命令 --skip-grant-tables &
来登录数据库的,所以不能使用grant
相关命令来进行权限赋值。操作系统
此时应先输入命令code
flush privileges;
以后再输入命令htm
grant all privileges on *.* to root@localhost identified by '123456';
便可执行成功,最后输入如下命令来查看用户权限是否变动blog
select * from user; #查看用户权限是否变动