使用phpMyAdmin过程中,在删除一条root@localhost的权限后,不知道什么原因root的用户丢失了所有权限。现象:控制台mysql-uroot-p能正常登陆,登陆后showgrants发现只有下面一个权限G...
使用phpMyAdmin过程中,在删除一条root@localhost的权限后,不知道什么原因root的用户丢失了所有权限。
现象:
控制台mysql -u root -p
能正常登陆,登陆后show grants
发现只有下面一个权限
GRANT USAGE ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*1A7CAB。。。。。。‘
现在root用户什么也干不了了,怎么回复root的权限。
网上搜了一下,也许用mysqld_safe --SKIP-GRANT-TABLES启动后来回复,
但是不知道怎么原因,运行mysqld_safe命令后又出现以下错误消息:
141111 20:22:41 mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
ps:我的mysql没有安装在/usr/local/mysql/而是安装在其他地方的
创建一个从/usr/local/mysql到mysql安装目录的软连接后 mysqld_safe能正常运行了,但是加了--SKIP-GRANT-TABLES启动后是不能运行grant命令。
mysql> grant ALL PRIVILEGES on *.* to root@"localhost" Identified by "root" WITH GRANT OPTION;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
自己解决了,mysqld_safe --skip-grant-tables启动
修改user表后
flush privileges;
就OK了
展开