如何理解MySQL 8.0中的全局参数持久化

  介绍

本篇内容介绍了”如何理解MySQL 8.0中的全局参数持久化”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

如何理解MySQL 8.0中的全局参数持久化”> <br/> </p> <p>自2018年从发布第一版<代码> MySQL 8.0.11 </代码>正式版至今,MySQL版本已经更新迭代到<代码> 8.0.26> </代码,相对于稳定的5.7版本来说,8.0在性能上的提升是毋庸置疑的! </p> <p>随着越来越多的企业开始使用MySQL 8.0版本,对于DBA来说是一个挑战,也是一个机遇! </p> <p>本文主要讨论下MySQL 8.0版本的新特性:<强>全局参数持久化</强>【相。关推荐:MySQL视频教程】</p> <h3> <强>全局参数持久化</强> </h3> <p> MySQL 8.0版本支持在线修改全局参数并持久化,通过加上<代码>坚持</代码>关键字,可以将修改的参数持久化到新的配置文件(mysqld-auto.cnf)中,重启MySQL时,可以从该配置文件获取到最新的配置参数! </p> <blockquote> <p> <强>对应的Worklog (WL # 8688): https://dev.mysql.com/worklog/task/?id=8688 </强> </p> </引用> <p>启用这个功能,使用特定的语法<代码>设置持续> </代码来设定任意可动态修改的全局变量! </p> <blockquote> <ul类= <李>

<强>设置保存

语句可以修改内存中变量的值,并且将修改后的值写?数据吗?录中的mysqld-auto.cnf中。

<李>

<强>设置PERSIST_ONLY

语句不会修改内存中变量的值,只是将修改后的值写?数据吗?录中的mysqld-auto.cnf中。

<强>以<代码> max_connections>

mysql>, select  *,得到performance_schema.persisted_variables;   Empty  set  (0.00, sec)      mysql>, show  variables  like  & # 39; % max_connections % & # 39;;   + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +   |,Variable_name ,,,,,,,,, |, Value  |   + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +   |,max_connections ,,,,,,, |, 151,, |   | |,mysqlx_max_connections  100年,,|   + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +   2,rows  set 拷贝;(0.00,sec)      mysql>, set  persist  max_connections=300;   Query 好吧,,0,rows  affected (0.00,秒)      mysql>, select  *,得到performance_schema.persisted_variables;   + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - +   |,VARIABLE_NAME ,, |, VARIABLE_VALUE  |   + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - +   | |,max_connections  300年,,,,,,,,,,,|   + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - +   1,row  set 拷贝;(0.00,sec)

系统会在数据目录下生成一个包含json代码 <代码>格式的mysqld-auto.cnf的文件,格式化后如下所示,和当my . cnf中所做mysqld-auto.cnf同时存在时,后者具有更高优先级。

{   ,,,“Version",, 1,,   ,,,“mysql_server":, {   ,,,,,,,“max_connections":, {   ,,,,,,,,,,,“Value":,“300,,,   ,,,,,,,,,,,“Metadata":, {   ,,,,,,,,,,,,,,,“Timestamp":, 1632575065787609,,   ,,,,,,,,,,,,,,,“User":,“root",,   ,,,,,,,,,,,,,,,“Host":,“localhost"   ,,,,,,,,,,,}   ,,,,,,,}   ,,,}   }

<>强注意:即使你通过<代码>设置保存修改配置的值并没有任何变化,也会写入到mysqld-auto.cnf文件中。但你可以通过设置成<代码>默认>

如果想要恢复<代码> max_connections> mysql>, set  persist  max_connections=违约;   Query 好吧,,0,rows  affected (0.00,秒)      mysql>, select  *,得到performance_schema.persisted_variables;   + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - +   |,VARIABLE_NAME ,, |, VARIABLE_VALUE  |   + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - +   | |,max_connections  151年,,,,,,,,,,,|   + - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - +   1,row  set 拷贝;(0.00,sec)

如果想要移除所有的全局持久化参数,则只需执行:

mysql>, RESET 坚持;   Query 好吧,,0,rows  affected (0.00,秒)      mysql>, select  *,得到performance_schema.persisted_variables;   Empty  set  (0.00, sec)

如何理解MySQL 8.0中的全局参数持久化