MySQL 根用户更新命令被拒绝
MySQL root user UPDATE command denied
我尝试使用 root 用户更改 sql_mode
全局变量
perfomance_schema.global_variables
table.
我尝试使用 SET GLOBAL sql_mode='???'
;
但它不起作用。
当我显示我的 root 授权时,我认为我拥有正确的权限:
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' 超级用户不能更新这个 table?
'root' 是否拥有正确的权利? MySQL 是否保护系统 tables?
要更改 sql_mode
变量,我需要 SUPER 特权而不是 ALL PRIVILEGES 吗?这就是 SET GLOBAL sql_mode
也不起作用的原因吗?
information_schema 通常是只读视图。
INFORMATION_SCHEMA 是每个 MySQL 实例中的一个数据库,该数据库存储有关 MySQL 服务器维护的所有其他数据库的信息。 INFORMATION_SCHEMA 数据库包含几个只读表。它们实际上是视图,而不是基表,因此没有文件与它们相关联,并且您不能在它们上设置触发器。此外,没有同名的数据库目录。
虽然您可以select INFORMATION_SCHEMA作为默认数据库使用 USE 语句,但您只能读取表的内容,不能对其执行 INSERT、UPDATE 或 DELETE 操作。
我尝试使用 root 用户更改 sql_mode
全局变量
perfomance_schema.global_variables
table.
我尝试使用 SET GLOBAL sql_mode='???'
;
但它不起作用。
当我显示我的 root 授权时,我认为我拥有正确的权限:
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' 超级用户不能更新这个 table? 'root' 是否拥有正确的权利? MySQL 是否保护系统 tables?
要更改 sql_mode
变量,我需要 SUPER 特权而不是 ALL PRIVILEGES 吗?这就是 SET GLOBAL sql_mode
也不起作用的原因吗?
information_schema 通常是只读视图。
INFORMATION_SCHEMA 是每个 MySQL 实例中的一个数据库,该数据库存储有关 MySQL 服务器维护的所有其他数据库的信息。 INFORMATION_SCHEMA 数据库包含几个只读表。它们实际上是视图,而不是基表,因此没有文件与它们相关联,并且您不能在它们上设置触发器。此外,没有同名的数据库目录。
虽然您可以select INFORMATION_SCHEMA作为默认数据库使用 USE 语句,但您只能读取表的内容,不能对其执行 INSERT、UPDATE 或 DELETE 操作。