We have Mysql running 5.5.25 and “expire_logs_days” is by default ‘0’. We have purged the logs using the command
PURGE BINARY LOGS TO ‘mysql-bin.xxxxxx’;. Plan to enable auto purge of mysql bin logs so I set the variable to retain the last 14 days logs as SET GLOBAL expire_logs_days=14. My question is do we need to add this parameter expire_logs_days in my.cnf, if so why? Having said that it is a global parameter it does not require to be added in my.cnf. If it is mandatory to add in my.cnf, do we need to restart the mysql instance to have the changes affective or just add in my.cnf and also set in variables without restarting the instance. Please suggest!!
expire_logs_days is dynamic variable and it’s value can be set without restarting MySQL however, if server restarts expire_log_days value will be reset and your changes will be lost. In order to make change permanent you can also add it in my.cnf and whenever mysql restarts it value will be persist which you already set previously without restarting via SET GLOBAL expire_log_days=14 You can read more about it here [url]MySQL :: MySQL 8.0 Reference Manual :: 5.1.8 Server System Variables
Hope that helps.
Thanks for clarifying Irfan.