输入banner图图片脚本导航/分类

【Linux0】mysql的root密码忘了怎么办?

(none)]> set password for root@localhost=password(123456);
#注:有些博客中使用了
update mysql.user set password=password("123456") where User="root" and Host="localhost";
的命令,但是总会出现‘Password‘ is not updatable‘的错误。
#注2:如果出现

The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
的报错的话,请刷新一下权限再修改root密码。

刷新权限的命令:
MariaDB [(none)]> flush privileges;

 

6、收尾工作

修改完毕后,停止mysql服务

net stop mysql

在/etc/my.cnf文件中,找到[mysqld]一行(如没有则请自行添加),在添加的skip-grant-tables前面加上#号将其无效化。

vim /etc/my.cnf

再次启动mysql服务

net start mysql

最后验证一下修改后的密码是否正确即可。

mysql -u root -p

 

【Linux0】mysql的root密码忘了怎么办?

标签:run   exec   --   inux   word   user   mariadb   学习linux   mys