如何在MySQL Windows中授予information_schema

时间:2018-11-10 08:16:09

标签: mysql

我试图授予information_schema,但是它给了我这个错误

首先我展示了我的赠款,但什么也没有:

mysql> show grants for root;
ERROR 1141 (42000): There is no such grant defined for user 'root' on host '%'

然后我尝试授予:

 mysql> grant select on information_schema.* to 'root'@'%' identified by   'password123';
 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual   that corresponds to your MySQL server version for the right syntax to use near    'identified by 'password123'' at line 1

但有表演资助; :

mysql> show grants;
 +--------------------------------------------------------------------------------   ---------------------------------------------------------------------------------   ---------------------------------------------------------------------------------   ---------------------------------------------------------------------------------   -----------------------------------------------------------------------+
 | Grants for root@localhost                                                                                                                                                                                                                                                                                                                                                                                    |
 +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN,   PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY  TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION   |
| GRANT   BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION _ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_ADMIN,XA_RECOVER_ADMIN  ON *.* TO `root`@`localhost` WITH GRANT OPTION                                                                                                    |
 | GRANT ALL PRIVILEGES ON `testdb`.* TO `root`@`localhost`                                                                                                                                                                                                                                                                                                                                                  |
 | GRANT ALL PRIVILEGES ON `%`.* TO `root`@`localhost`                                                                                                                                                                                                                                                                                                                                                      |
 | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION                                                                                                                                                                                                                                                                                                                                             |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 5 rows in set (0.00 sec)

我也尝试过这个,但是有错误:

mysql> GRANT ALL PRIVILEGES ON 'information_schema'.* TO 'root'@'localhost';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual   that corresponds to your MySQL server version for the right syntax to use near   ''information_schema'.* TO 'root'@'localhost'' at line 1

如何授予我的information_schema?

1 个答案:

答案 0 :(得分:0)

  1. 授予特权的语法应类似于:
GRANT ALL PRIVILEGES ON testDB.* TO 'root'@'localhost' identified by 'test';

注意::数据库名称将不在引号内。

在克服语法错误之后,我们也无权向information_schema数据库授予任何特权。

  1. SHOW GRANTS;SHOW GRANTS FOR CURRENT_USER;都显示当前用户的所有授予的特权。要查看root用户授权,您需要以root用户身份登录,然后执行上述命令。