Advertisement
Tritonio

Changing expire_log_days in MYSQL

Oct 20th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. In MySQL 5.6, you would want to show what your expire_logs_days is set to first. Then confirm that the master doesnt need to keep these logs more than x amount of days. Word of caution, having binary logs that low in days can be a big risk.
  2.  
  3. Set globally as:
  4.  
  5. mysql> show variables like 'expire_logs_days';
  6. +------------------+-------+
  7. | Variable_name | Value |
  8. +------------------+-------+
  9. | expire_logs_days | 5 |
  10. +------------------+-------+
  11. 1 row in set (0.00 sec)
  12. mysql> set global expire_logs_days=1;
  13. Query OK, 0 rows affected (0.62 sec)
  14. mysql> show variables like 'expire_logs_days';
  15. +------------------+-------+
  16. | Variable_name | Value |
  17. +------------------+-------+
  18. | expire_logs_days | 1 |
  19. +------------------+-------+
  20. 1 row in set (0.00 sec)
  21. Then dont forget to update the my.cnf file if you want this setting to remain or survive a service restart:
  22.  
  23. $ sudo vim /etc/mysql/my.cnf
  24. expire_logs_days = 1
  25. Then flush the current log and to have the binary log statement to take effect on all the logs older than 1 day, in your case:
  26.  
  27. mysql> flush binary logs;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement