1

AFTER update user set host='%' where user='root, I lost some of the privileges from my MySQL root user. So I stopped the server and started it with --skip-grant-tables

msqld --skip-grant-tables

and I tried

mysql>update mysql.user set grant_priv = 'Y' where user = 'root';
Query OK, 0 rows affected (0.00 sec)
mysql>FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

This doesn't work for me. When I log in as root, I still can't see the MYSQL database.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
+--------------------+
2 rows in set (0.00 sec)

Please help. I've tried all the solutions still can't restore the privileges for ROOT, always got the "0 row affected" result.

4

1 回答 1

2

尝试

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

更新

运行此命令以检查您当前的权限

SHOW GRANTS FOR CURRENT_USER; 

使用直接 SQL DML 语句从mysql.*表和表中插入/更新/删除是一种不好的做法。information_schema.*

更新 2

你能发布这个命令的结果吗

  SELECT (
      Host, 
      Grant_priv, 
      Super_priv 
    ) 
  FROM mysql.user
  WHERE user = 'root';

所有的_priv列都应该有一个值YHost应该是localhost

于 2013-11-12T03:38:06.633 回答