Difference between revisions of "Mysqldump"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
 
(27 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{lc}}
 
<code>mysqldump</code><ref>https://linux.die.net/man/1/mysqldump</ref> a [[backup]] program.
 
<code>mysqldump</code><ref>https://linux.die.net/man/1/mysqldump</ref> a [[backup]] program.
  
 +
[[mysqldump --help]]
 +
[[mysqldump --single-transaction]]
 +
[[mysqldump --skip-lock-tables]]
  
== Usage ==
+
== Create backup ==
* <code>mysqldump database_name > database_name.sql</code>  
+
* <code>mysqldump DB_name > DB_name.sql</code>  
** Compressing from <code>[[stdin]]</code> <code>mysqldump database_name | [[gzip]] > database_name.sql.gz</code>  
+
** Compressing from <code>[[stdin]]</code>  
** Compressing from <code>[[stdin]]</code> <code>mysqldump database_name | [[xz]] > database_name.sql.xz</code>  
+
*** <code>mysqldump DB_name | [[gzip]] > DB_name.sql.gz</code>  
 +
*** <code>mysqldump DB_name | [[xz -T0]] > DB_name.sql.xz</code>
  
== Related commands ==
+
* <code>mysqldump -u root -p --all-databases</code>
 +
 
 +
* <code>mysqldump -u root -ppassword [[--flush-logs]] [[--delete-master-logs]]  [[--all-databases]] > full-backup.sql</code>
 +
 
 +
== Restore backup ==
 +
[[create database]] DB_name;
 +
mysql -u root -p DB_name < /path/to/file/DB_name.sql
 +
 
 +
== Related ==
 
* <code>[[mongodump]]</code>
 
* <code>[[mongodump]]</code>
* <code>[[mariabackup]]<code>
+
* <code>[[pg_dump]]</code>
 +
* <code>[[mariabackup]]</code> (since 2017)
 +
* <code>[[mysql]]</code>
 +
* <code>[[mysqldumpslow]]</code>
 +
* [[Snapshot]]
 +
* <code>[[--single-transaction]]</code>
 +
 
 +
[[set -o pipefail]]
 +
mysqldump [...] | restic -r /srv/restic-repo backup --stdin
 +
 
 +
== Activities ==
 +
* Read https://stackoverflow.com/questions/104612/run-mysqldump-without-locking-tables
  
 
== See also ==
 
== See also ==
 +
* {{mysqldump}}
 
* {{MariaDB}}
 
* {{MariaDB}}
 +
* {{MySQL}}
 
* [[XtraBackup]] and [[MyDumper]]  
 
* [[XtraBackup]] and [[MyDumper]]  
 
* {{dbdump}}
 
* {{dbdump}}
 +
  
  
 
[[Category:Databases]]
 
[[Category:Databases]]
 
[[Category:Backup]]
 
[[Category:Backup]]

Latest revision as of 06:34, 9 June 2024

mysqldump[1] a backup program.

mysqldump --help
mysqldump --single-transaction
mysqldump --skip-lock-tables

Create backup[edit]

  • mysqldump DB_name > DB_name.sql
    • Compressing from stdin
      • mysqldump DB_name | gzip > DB_name.sql.gz
      • mysqldump DB_name | xz -T0 > DB_name.sql.xz
  • mysqldump -u root -p --all-databases

Restore backup[edit]

create database DB_name;
mysql -u root -p DB_name < /path/to/file/DB_name.sql

Related[edit]

set -o pipefail
mysqldump [...] | restic -r /srv/restic-repo backup --stdin

Activities[edit]

See also[edit]

  • https://linux.die.net/man/1/mysqldump
  • Advertising: