Is it possible to "backup" a row / table using mysqldump or any other

Suppose a row (several rows) or a table in a database. Can I create a backup so that I can restore them as soon as possible if the rows / table gets corrupted.

Thank you in advance!

+3
source share
3 answers

I use the following perl-script to backup my databases:

#!/usr/bin/perl
use strict;
use DBI;
my $dbh = DBI->connect( "dbi:mysql:database=;mysql_client_found_rows=0;host=your.database.host", "username", "password", {RaiseError => 1});
my $databases = $dbh->selectcol_arrayref('SHOW databases;');
foreach my $t (@{$databases}) {
   system('/usr/local/bin/mysqldump -h your.database.host --add-drop-database --add-drop-table --add-locks --extended-insert=false --databases --allow-keywords -c -e -f -u username  --password=password \''.$t.'\' > /path/to/backupfiles/'.$t.'.sql');
   print "$t done\n";
   sleep(2);
}

Mysql-dump command:

/ usr / local / bin / mysqldump -h your.database.host --add-drop-database -add-drop-table -add-locks -extended-insert = false -databases -allow -keywords -c -e -f -u username --password = password 'databasename'> /path/to/backupfiles/databasename.sql

- . , . , , . , .

, . script .

script, , .

+3

mysqldump -u -p mydatabase table1 > table1.sql

--where .

mysql -u -p mydatabase < table1.sql
+3

If you want to do this using the graphical interface, you can use PhpMyAdmin to create SELECTand then use the "export this query" function - this gives you to export in various formats, including SQL (which you can then execute directly when you need to restore)

+2
source

All Articles