Saturday, October 8, 2011

Using and Creating a MySQL Dump

To use a database dump:
mysql -u <username> -p  <database_schema> < schema_dump.sql

To create a dump for the whole database:
mysqldump -u <username> -p  <database_schema> > schema_dump.sql

To create a dump of only a specific table of the database:
mysqldump -u <username> -p <database_schema> <table_name> > table_dump.sql

To create a compressed dump all of the databases on your MySQL:
mysqldump --all-databases -p | bzip2 -c > databasebackup.sql.bz2

Just make sure to enter the correct values on the parts enclosed between < and >.

No comments:

Post a Comment