Why MySQL filled up my harddrive
I run nightly backup scripts, which email me a summary report that includes, among other things, information on disk usage.
I'd been watching the percentage creep steadily up on my main (root) mount drive with increasing concern, but not sufficient concern to actually investigate what the culprit was and whether or not it was a legitimate use of drive space.
Except the other day the percentage finally got dangerously close to 100%, so I finally had to stop putting it off and figure out what was going on.
Turns out it was embarrassingly simple. MySQL was happily generating binary log files which tracked Every Single Thing it did, ever, all the time. Just like it was told to do by my /etc/mysql/my.cnf file (via the 'log-bin' option). Only apparently the files never go away and don't participate in the normal logrotate process (for obvious reasons, once you understand the purpose of the binary logs). So they just keep piling up, indefinitely. To the tune of ~25GB, in my case, for a small set of low-footprint MySQL databases running since about 2006.
Once I understood the situation, it was easily remedied by adjusting the options I supplied to the nightly run of mysqldump (which is what I employ as my MySQL backup method):
--flush-privileges --flush-logs --delete-master-logs --master-data=2
The critical one was '--delete-master-logs', not surprisingly, but the other ones came along for the ride as I waded through the mysqldump man pages.
"Why not just disable binary logging", you ask. Because they're actually a good thing, which is why they're enabled by default. In a disaster recovery scenario, they let you bridge the gap between your last full backup and whatever transactions occurred until the point of the disaster. The issue wasn't that they were being generated, it was that they weren't being cleaned up each time I did a full backup (at which point they become superfluous).
So.. the moral of the story is the age-old lesson that computers always do precisely what you've told them to do, whether you actually want what you asked for or not.