Backing Up Data


Like all data, MySQL data must be backed up regularly. As MySQL databases are disk-based files, normal backup systems and routines can back up MySQL data. However, as those files are always open and in use, normal file copy backup may not always work.

Here are possible solutions to this problem:

  • Use the command line mysqldump utility to dump all database contents to an external file. This utility should ideally be run before regular backups occur so the dumped file will be backed up properly.

  • The command line mysqlhotcopy utility can be used to copy all data from a database (this one is not supported by all database engines).

  • You can also use MySQL to dump all data to an external file using BACKUP TABLE or SELECT INTO OUTFILE. Both statements take the name of a system file to be created, and that file must not already exist or an error will be generated. Data can be restored using RESTORE TABLE.

Tip

Flush Unwritten Data First To ensure that all data is written to disk (including any index data) you might need to use a FLUSH TABLES statement before performing your backup.





MySQL Crash Course
MySQL Crash Course
ISBN: 0672327120
EAN: 2147483647
Year: 2004
Pages: 214
Authors: Ben Forta

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net