MySQL 8 新特性之持久化全局变量的修改
在8之前的版本中,对于全局变量的修改,其只会影响其内存值,而不会持久化到配置文件中。数据库重启,又会恢复成修改前的值。从8开始,可通过SET PERSIST命令将全局变量的修改持久化到配置文件中。
试举一例
mysql> show variables like '%max_connections%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | max_connections | 151 | | mysqlx_max_connections | 100 | +------------------------+-------+ 2 rows in set (0.00 sec) mysql> set persist max_connections=200; Query OK, 0 rows affected (0.00 sec) mysql> show variables like '%max_connections%'; +------------------------+-------+ | Variable_name | Value | +------------------------+-------+ | max_connections | 200 | | mysqlx_max_connections | 100 | +------------------------+-------+ 2 rows in set (0.00 sec)
[root@slowtech ~]# cat /var/lib/mysql/mysqld-auto.cnf { "Version" : 1 , "mysql_server" : { "max_connections" : { "Value" : "200" , "Metadata" : { "Timestamp" : 1525509217566258 , "User" : "root" , "Host" : "localhost" } } } }
mysql> select * from performance_schema.persisted_variables; +-----------------+----------------+ | VARIABLE_NAME | VARIABLE_VALUE | +-----------------+----------------+ | max_connections | 200 | +-----------------+----------------+ 1 row in set (0.00 sec)
mysql> set persist max_connections=default;