MySQL GRANT命令执行时发生root权限错误问题
2559 点击·0 回帖
![]() | ![]() | |
![]() | MySQL GRANT命令执行时发生root权限错误 在MySQL节点执行GRANT命令为SPIDER服务器进行授权时,发生了如下错误: mysql> GRANT ALL ON *.* TO 'spider'@'spiderdb' IDENTIFIED BY 'spider'; ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) www.atcpu.com 可是我就是使用root用户登录的,root的password也是空的,怎么可能会发生这个错误呢。 网上有相同的错误,是登录不进MySQL的解决办法。如果是忘记了密码,可以用下边的方法: # /etc/init.d/mysql stop # mysqld_safe -u mysql --skip-grant-tables --skip-networking ; # mysql -u mysql mysql> UPDATE user SET Password=PASSword('newpassword')where USER='root'; mysql> FLUSH PRIVILEGES; mysql> exit www.atcpu.com # /etc/init.d/mysqld restart # mysql -uroot -pnewpassword www.atcpu.com 可是这个方法却解决不了我的问题。 网上还有一种办法,删除user.user中值为NULL的(delete from user where user is NULL),或更新NULL为test(update user set user=‘test‘ where user is NULL)。但是也不好使。 偶然发现对于单个DB的授权是没有问题的,难道是root没有特定DB的权限?写了个script对于每个database执行"GRANT ALL ON $DATABASE.* TO 'root'@'localhost' IDENTIFIED BY 'cps-pt' with grant option;",居然是information_schema的时候出错了。 前两天同志执行dump/restore的时候,DB曾经死掉过,难道information_schema被破坏掉了。 这好像是MySQL的一个restore时的bug。 | |
![]() | ![]() |