MySQL root用户UPDATE命令被拒绝

时间:2018-08-23 08:06:22

标签: mysql configuration rights

我尝试使用root用户更改sql_mode全局变量 perfomance_schema.global_variables表。

我尝试使用SET GLOBAL sql_mode='???';

但是它不起作用。

当我显示我的根资助时,我认为我拥有正确的权利:

libertalia@labuse:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    mysql> show grants;
    +---------------------------------------------------------------------+
    | Grants for root@localhost                                           |
    +---------------------------------------------------------------------+
    | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
    | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
    +---------------------------------------------------------------------+
    2 rows in set (0,00 sec)

下一步,我尝试更改sql_mode全局变量:

mysql> use performance_schema
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> describe global_variables;
+----------------+---------------+------+-----+---------+-------+
| Field          | Type          | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| VARIABLE_NAME  | varchar(64)   | NO   |     | NULL    |       |
| VARIABLE_VALUE | varchar(1024) | YES  |     | NULL    |       |
+----------------+---------------+------+-----+---------+-------+
2 rows in set (0,01 sec)

mysql> SELECT * FROM global_variables WHERE VARIABLE_NAME = 'sql_mode';
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| VARIABLE_NAME | VARIABLE_VALUE                                                                                                                            |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| sql_mode      | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0,01 sec)

mysql> UPDATE global_variables SET VARIABLE_VALUE = 'ONLY_FULL_GROUP_BY,ALLOW_INVALID_DATES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' WHERE VARIABLE_NAME = 'sql_mode';
ERROR 1142 (42000): UPDATE command denied to user 'root'@'localhost' for table 'global_variables'

我不明白为什么我的“ root”超级用户无法更新此表? “ root”拥有正确的权利吗? MySQL是否保护系统表?

要更改sql_mode变量,我是否需要SUPER特权,但不需要ALL PRIVILEGES?这就是为什么SET GLOBAL sql_mode也不起作用的原因吗?

1 个答案:

答案 0 :(得分:0)

information_schema通常是本质上只读的视图。

INFORMATION_SCHEMA是每个MySQL实例中的一个数据库,该位置存储有关MySQL服务器维护的所有其他数据库的信息。 INFORMATION_SCHEMA数据库包含几个只读表。它们实际上是视图,而不是基表,因此没有与它们关联的文件,并且您不能在它们上设置触发器。另外,没有具有该名称的数据库目录。

尽管您可以使用USE语句选择INFORMATION_SCHEMA作为默认数据库,但是您只能读取表的内容,而不能对它们执行INSERT,UPDATE或DELETE操作。