Backup mysql from files

1

I have problems running MySQL (I'm in rescue disk and can't run anything) and I would like to backup up the databases from the system files because I'm planning on formatting the system. How can I do that?

Thank you.

The Quantum Physicist

Posted 2014-01-23T10:38:53.410

Reputation: 648

Answers

3

If your system is not completely dead (i.e. MySQL service can be started):

1) Boot from rescue media

2) Mount your system disk

mount /dev/sdX /mnt/tmp

3) Mount virtual filesystems

mount -o bind /dev /mnt/tmp/dev
mount -t proc proc /mnt/tmp/proc
mount -t sysfs sys /mnt/tmp/sys

4) Change root

chroot /mnt/tmp

5) When you're in chroot'ed environment, start MySQL service

/etc/init.d/mysql start

6) Make db backup as you do it normally

Don't forget to check your backup before formatting; you can also backup raw MySQL db files, backups never hurt.

barti_ddu

Posted 2014-01-23T10:38:53.410

Reputation: 1 286

0

Here are two things you can try.
The first might work the second ought to work but is more complicated.

  1. Copy the database files (usually found at $SOMEPATH/mysql/data). Make a fresh installation of mysql (use same version and os as the source). Dump the database files in the new installations data dir. Start mysql and it might work.

  2. Mount the disk on a working computer. Use "Percona Xtrabackup" ta take a backup of the data. Then use that backup to restore. (don't ask how to use Xtrabackup, read the docs)

Nifle

Posted 2014-01-23T10:38:53.410

Reputation: 31 337

Make sure the rights are identical. Use cp -rp or rsync to be sure. – SPRBRN – 2014-01-23T12:42:52.287