Backing up MySQL on Linux

Yohhan

Limp Gawd
Joined
May 17, 2002
Messages
220
I'm trying to figure out how to backup MySQL on my Linux machine. I've never really used it before. Does anyone know the default directory where data files are kept? In order to back it up, can I just copy the data files if something goes wrong, reinstall MySQL and then copy them back over? Or is it not that simple?
 
Generally, it isn't that easy to backup a database. Usually, you have to export your data using SQL queries and back up that along with the transaction logs. It really depends on the complexity of your database, though. For an extremely simple database, it may be enough to simply backup the data files.
 
Read the MySQL manual on doing backups. There are utilities that make it easy to dump the database contents, both schema and data, into files that can be read back in if necessary. The only problem with that is you don't get the logs, which requires another step.
 
heres something i came across:
mysqldump --opt <dbname> <file>
you can also pipe it through gzip or bz2:
mysqldump --opt <dbname> | bzip2 > <file>
i do not use sql myself, so check in the man pages for the options to sqldump
 
If you have a copy of phpmyadmin on the site you can eaily export the databses from there. You can select to save it to a file, zip it, and then store it whereever you want.

Google around, there are also several automated scripts that you can put in cron that will backup the dbs for you and do things like email/ftp them off location for you.
 
Back
Top