Резервное копирование MySQL из файлов

1531
The Quantum Physicist

У меня проблемы с запуском MySQL (я на аварийном диске и ничего не могу запустить), и я хотел бы сделать резервную копию баз данных из системных файлов, потому что я планирую отформатировать систему. Как я могу это сделать?

Спасибо.

1

2 ответа на вопрос

3
barti_ddu

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.

0
Nifle

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)

Убедитесь, что права идентичны. Используйте `cp -rp` или rsync, чтобы быть уверенным. SPRBRN 10 лет назад 0