介绍
本篇内容介绍了”如何理解MySQL 8.0中的全局参数持久化”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
<李>
<强>设置保存强>
李> 引用>语句可以修改内存中变量的值,并且将修改后的值写?数据吗?录中的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中的全局参数持久化