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
RESET MASTER to remove them.
I would also then stop the server, and add a new configuration variable to your my.cnf.
expire_log_days will tell the server to keep the binary logs for the amount of days you specify, to prevent further buildup in the future.
You could also turn off binary logging by making sure the
bin_log option is not set, but this is not the recommended route. A better solution would be to develop a backup and restore strategy so that if you do have a database crash, you can recover from it.
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.