要列出使用 PERSIST 选项更新的变量,我们可以查询 performance_schema.persisted_variables 表以及其他几个表,如下所示。这是一个如何从 MySQL 端监视变量的简单示例,您可以根据需要修改查询。mysql> select v.VARIABLE_NAME,g.VARIABLE_VALUE current_value,p.VARIABLE_VALUE as persist_value,SET_TIME,SET_USER,VARIABLE_SOURCE,VARIABLE_PATH from performance_schema.variables_info v JOIN performance_schema.persisted_variables p USING(VARIABLE_NAME) JOIN performance_schema.global_variables g USING(VARIABLE_NAME)\G
*************************** 1. row ***************************
VARIABLE_NAME: innodb_log_file_size
current_value: 50331648
persist_value: 100663296
SET_TIME: 2020-10-12 18:54:35.725177
SET_USER: arun
VARIABLE_SOURCE: COMPILED
VARIABLE_PATH:
*************************** 2. row ***************************
VARIABLE_NAME: max_connections
current_value: 1000
persist_value: 1000
SET_TIME: 2020-10-12 18:53:19.336115
SET_USER: root
VARIABLE_SOURCE: DYNAMIC
VARIABLE_PATH:
2 rows in set (0.06 sec)
mysql> restart;
Query OK, 0 rows affected (0.01 sec)
select v.VARIABLE_NAME,g.VARIABLE_VALUE current_value,p.VARIABLE_VALUE as persist_value,SET_TIME,SET_USER,VARIABLE_SOURCE,VARIABLE_PATH from performance_schema.variables_info v JOIN performance_schema.persisted_variables p USING(VARIABLE_NAME) JOIN performance_schema.global_variables g USING(VARIABLE_NAME)\G
*************************** 1. row ***************************
VARIABLE_NAME: innodb_log_file_size
current_value: 100663296
persist_value: 100663296
SET_TIME: 2020-10-12 18:54:35.725177
SET_USER: arun
VARIABLE_SOURCE: PERSISTED
VARIABLE_PATH: /var/lib/mysql/mysqld-auto.cnf
*************************** 2. row ***************************
VARIABLE_NAME: max_connections
current_value: 1000
persist_value: 1000
SET_TIME: 2020-10-12 18:53:19.335909
SET_USER: root
VARIABLE_SOURCE: PERSISTED
VARIABLE_PATH: /var/lib/mysql/mysqld-auto.cnf
2 rows in set (0.16 sec)