admin管理员组

文章数量:1647981

使用root用户给一个账户执行grant命令的时候报了权限问题,然后就查看mysql的user表看看root有哪些权限。发现有几个权限是N,然后顺手就改成了Y。结果一刷新之后就凉凉了。Account is locked。

原因:

于是大致搜了一下,发现是我把user表中的account_locked字段设为了N。

解决:

1、关闭mysql服务:

service mysql stop

2、用安全模式进入:

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

进入后台运行,然后ctrl + c退出就行。

3、使用免密方式登录mysql:

mysql -uroot

4、登录上之后,执行解除上锁语句

先执行一下 flush privileges 否则会报错: The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement。

flush privileges;
ALTER USER 'root'@'localhost' ACCOUNT UNLOCK;
ALTER USER 'root'@'%' ACCOUNT UNLOCK;
update mysql.user set account_locked='N' where user='root';
commit;

注意要 commit

5、退出mysql,重启服务:

service mysql restart

本文标签: 报错用户lockedAccount