I have over 500 files in my /var/lib/mysql folder named mysql-bin.000522 (or some variation thereof)...each is anywhere from a couple megabytes to 1.1GB. Overall, these files are taking up >400GB on our system. How are these being created? Are they safe to delete? If they're not necessary, how can we prevent them from being re-created?
It's all in the MySQL documentation that they are binary log files for data recovery and synchronizing.
Look at the documentation on how to get rid of them. But make sure that you don't need them in your current setup.
As already mentioned those files are for binary logging. If you're not using them, you can issue a
I would also then stop the server, and add a new configuration variable to your my.cnf.
You could also turn off binary logging by making sure the
One such example, on a low-write server, would be to take a full backup once weekly. Then you would have the binary logs for 7 days (14 to be safe) to replay any changes from the full backup.
Here is what MySQL has to say about backing up and restoring.