Place Holder Products Code
Bash MySQL
Notes Return of the Fed Login
Admin Control Panel Email Control Panel Product Control Panel Debug Info Beacon Create Snippet Tag Control Panel

Backup MySQL Database or Table Using mysqldump

Backup a MySQL Database entirely, or just a selected series of tables using mysqldump.

mysqldump --add-drop-table -u username -ppassword databasename tbl_one tbl_two > outputfile.sql

This creates a file which if executed as MySQL will recreate the dumped table(s) complete with the data contained in each.

--add-drop-table adds a DROP TABLE IF EXISTS tblName line before each table creation in the output file.  This recreates the table from scratch each time, and is useful if using mysqldump as part of a backup or development <-> production routine.

-u and -p pass the MySQL server login creds.  If -p is present, but no password follows (note the LACK of a space between switch and the password) mysqldump will prompt for a password.

Multiple tables may be specified separated by spaces after the database name.  If no tables are specified, the entire database is dumped.


No Comments Yet!