Skip to main content

MySQL Backups

This article only covers backing up from the Command Linux (i.e., the shell, usually bash or korn (ksh) shells).

If you wanted to back up the database timsdata, you would simply use a command like:

mysqldump -c -u tim -p timsdata > *timsdata.sql*

This would create a file called *timsdata.sql* in the current directory. You should be aware that where I've entered the name tim in italics, you should specify another authorized user for the database.

Now you have a single file with all the sql to completely (the -c option specified in the command line) rebuild a new database. A command like:

mysql newdb -u tim -p < timsdata.sql

will create all the necessary tables in the database newdb. NOTE: This assumes that the user tim has permissions to the database and can create objects in the database newdb. It will fail if the user doesn't have sufficient permissions. See the reference manual for more information.