灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:1982回复:0

[mysql]MySQL GRANT命令执行时发生root权限错误问题

楼主#
更多 发布于:2012-09-01 02:18

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。




喜欢0 评分0
游客

返回顶部