MySQL/MariaDB database quick backup/restore commands

Backup

Backup a certain database;
$ mysqldump -u dbUser -p dbName > dbBackup.sql;

Backup a certain table;
$ mysqldump -u dbUser -p dbName tableName > dbTableBackup.sql;

Backup all the databases;
$ mysqldump -u dbUser -p --all-databases > allDbBackup.sql;

Optional parameters:
-lock-all-tables
-quick
-complete-insert
-no-create-db
-no-create-info

Restore

Restore a certain database;
$ mysql -u dbUser -p dbName < dbBackup.sql

Restore all databases;
$ mysql -u dbUser -p < backup.sql

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。