MySQL 8.0 New Features - persistent global variables

In previous versions, to modify global variables, which only affect the value of its memory and will not persisted to the configuration file. Restart the database, will return to the value before the modification. 8.0 From the beginning, through the SET PERSIST command to modify global variables persisted to the configuration file.

>show variables like 'max_connections';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| max_connections        | 151   |
+------------------------+-------+
1 rows in set (0.01 sec)

>set global.max_connections=155;
Query OK, 0 rows affected (0.00 sec)

>show variables like 'max_connections';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| max_connections        | 155   |
+------------------------+-------+
1 rows in set (0.01 sec)

  

View persistence of variables

After modification, data directory will be more of a file mysqld-auto.cnf. You can view the file directly

# more mysqld-auto.cnf
{ "Version" : 1 , "mysql_server" : { "max_connections" : { "Value" : "155" , "Metadata" : { "Timestamp" : 1585748279787787 , "User" :
 "root" , "Host" : "localhost" } } } }

You can also view the list by:

mysql> select * from performance_schema.persisted_variables;
+-----------------+----------------+
| VARIABLE_NAME   | VARIABLE_VALUE |
+-----------------+----------------+
| max_connections | 160            |
+-----------------+----------------+
1 row in set (0.00 sec)

When the database starts, you will first read the other configuration files, and finally read the file mysqld-auto.cnf

 

Execution set persist require different permissions, depending on the type of system variables:
Dynamic system variables, set persist system_variables_admin need permission or super
-read-only system variables, set persist persist_ro_variables_admin rights and needs system_variables_admin

Variables set persist settings take effect only when run, will also write the variable-auto.cnf mysqld
the SET persist_only variable write mysqld-auto.cnf, but does not affect the value of the variable at runtime. Take effect after reboot.

Remove persistent variables
· reset persist: remove mysqld-auto.cnf all variables
· reset persist system_var_name: remove mysqld-auto.cnf in the variable named system_var_name
· reset persist IF exists system_var_name: If the variable does not exist, not being given, will be given prompt warning

Note that only empty mysqld-auto.cnf and content performance_schema.persisted_variables in, for the value of the variable has been modified and will not have any effect.

In the following manner into the persistent global variables default value. Note that the default value, rather than the value before the amendment.
mysql> set persist max_connections = default;

This command with "set global max_connections = default" Similarly, the value of the variable will be set to default values, but the former will be the default value of persistence in the configuration file.

Guess you like

Origin www.cnblogs.com/abclife/p/12616580.html