Skip to content

Instantly share code, notes, and snippets.

@khavari
Last active August 21, 2022 11:48
Show Gist options
  • Save khavari/f45a188b7b6052a113fa3f839bd7ed7f to your computer and use it in GitHub Desktop.
Save khavari/f45a188b7b6052a113fa3f839bd7ed7f to your computer and use it in GitHub Desktop.

Single database backup

sudo mysqldump -u root -p database_name > /var/www/dump/file_name.sql

Multiple databases backup

sudo mysqldump -u root -p --all-databases > /var/www/dump/file_name.sql
sudo mysqldump -u root -p --databases db_name_1 db_name_2 > /var/www/dump/file_name.sql

Multiple tables backup

sudo mysqldump -u root -p database_name tbl_name_1 tbl_name_2 > /var/www/dump/file_name.sql

Database structure backup

sudo mysqldump -u root -p database_name --no-data > /var/www/dump/file_name.sql

Database data backup

sudo mysqldump -u root -p database_name --no-create-info --complete-insert > /var/www/dump/file_name.sql

Database data backup, Ignore table, Complete insert command

sudo mysqldump -u root -p database_name --no-create-info --complete-insert --ignore-table=database_name.migrations > /var/www/dump/file_name.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment