【发布时间】:2019-01-29 13:14:31
【问题描述】:
我尝试使用 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 也不起作用的原因吗?
【问题讨论】:
标签: mysql configuration rights