KNOWNHOST WIKI

User Tools

Site Tools


developmental:create-or-restore-mysql-mariadb-backups-ssh-command-line

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developmental:create-or-restore-mysql-mariadb-backups-ssh-command-line [2018/03/20 20:02]
Daniel P. created
developmental:create-or-restore-mysql-mariadb-backups-ssh-command-line [2019/10/11 12:18] (current)
Karson N.
Line 12: Line 12:
 ''​mysqldump database | gzip > database_backup.sql.gz''​ ''​mysqldump database | gzip > database_backup.sql.gz''​
  
-{{:​developmental:​backup1.png?​direct&400|}}+{{:​developmental:​backup1.png?​nolink&800|}}
  
 This dumps the database and compresses it with one line of commands, and is the most common way to backup a MySQL database. Further, you can specify more than one database, like so: This dumps the database and compresses it with one line of commands, and is the most common way to backup a MySQL database. Further, you can specify more than one database, like so:
Line 18: Line 18:
 ''​mysqldump --databases database1 database2 database3 | gzip > database123_backup.sql.gz''​ ''​mysqldump --databases database1 database2 database3 | gzip > database123_backup.sql.gz''​
  
-{{:​developmental:​multi-database.png?​direct&400|}}+{{:​developmental:​multi-database.png?​nolink&800|}}
  
 You can also specify specific tables that you'd like to dump and backup, with a command like the one below: You can also specify specific tables that you'd like to dump and backup, with a command like the one below:
Line 24: Line 24:
 ''​mysqldump database tablename [tablename2,​ tablename3, etc] | gzip > database_table.sql.gz''​ ''​mysqldump database tablename [tablename2,​ tablename3, etc] | gzip > database_table.sql.gz''​
  
-{{:​developmental:​tables.png?​direct&400|}}+{{:​developmental:​tables.png?​nolink&800|}}
  
 If you want to dump multiple tables from different databases, you'll need to use an and_if command to continue writing to the backup, like so: If you want to dump multiple tables from different databases, you'll need to use an and_if command to continue writing to the backup, like so:
Line 32: Line 32:
 ''​rm database_tables.sql''​ [y] ''​rm database_tables.sql''​ [y]
  
-{{:​developmental:​multi-database.png?​direct&400|}}+{{:​developmental:​multi-database.png?​nolink&800|}}
  
 Lastly, if you need to make a backup of all of your databases, you can use the following command: Lastly, if you need to make a backup of all of your databases, you can use the following command:
Line 38: Line 38:
 ''​mysqldump --all-databases | gzip > all_databases.sql.gz''​ ''​mysqldump --all-databases | gzip > all_databases.sql.gz''​
  
-{{:​developmental:​all_databases.png?​direct&400|}}+{{:​developmental:​all_databases.png?​nolink&800|}}
  
 ===== Importing a MySQL database ===== ===== Importing a MySQL database =====
Line 47: Line 47:
 ''​zcat my_database_backup.sql.gz | mysql mydatabase''​ ''​zcat my_database_backup.sql.gz | mysql mydatabase''​
  
-{{:​developmental:​zcat_gunzip.png?​direct&400|}}+{{:​developmental:​zcat_gunzip.png?​nolink&800|}}
  
 If the database is not compressed, you can use the following command: If the database is not compressed, you can use the following command:
Line 71: Line 71:
 ''​mysql desired_database < database_with_changed_table.sql''​ ''​mysql desired_database < database_with_changed_table.sql''​
  
-{{:​developmental:​sed_nonsense.png?​direct&400|}}+{{:​developmental:​sed_nonsense.png?​nolink&800|}}
  
 ===== Importing multiple databases at once ===== ===== Importing multiple databases at once =====
developmental/create-or-restore-mysql-mariadb-backups-ssh-command-line.1521576128.txt.gz · Last modified: 2018/03/20 20:02 by Daniel P.