Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Creating a quick dump for your mysql database (See related posts)

Doing dumps is a common task but I always forget exact code to do that, and looking for exact page manual is dull. Here goes the generic code:

Mysql Pre-4.1
mysqldump -u username -p password --quick [database [table1, table2, ...]] > backup_db.sql

4.1 and up
mysqldump -u username -p password [database [table1, table2, ...]] > backup_db.sql

Great for doing maintenance backups via cron, or just occasional dumps for off-site storage and archival.

And useful shorthand for the manual:

Comments on this post

Andrew posts on Jun 30, 2005 at 20:57
You may also find yourself running into this error on Textdrive:

mysqldump: Got error: 1044: Access denied for user 'username'@'localhost' to database 'username-foo' when using LOCK TABLES

If this is the case, you may get around it by using the "--skip-opt" option, i.e.

mysqldump --skip-opt -u username -p username-foo > backup_db.sql
ubs posts on Jul 01, 2005 at 05:06
Yeah, thanks. And I would add that with "--skip-opt" option it would be useful to use "--quick" flag as well to make dump fast.
ubs posts on Jul 05, 2005 at 12:46
Relevant forum thread:
MySQL database - Backup

You need to create an account or log in to post comments to this site.

Related Posts