miércoles, enero 07, 2009

Making a MySQL dump via chroot.

At the office, we used to have this RedHat Based distro with a MySQL database in, wich was on a RAID 0, in case of Disk failure, BUT, we never tougth that the Software would fail -_-'.

One day, the server itself installed an upgrade and messed up all the installation of Our linux.

Now we couldnt access to the last kernel image, because for some reason it erased our init, so we where having the old message "Kernel Panic, INIT not found, try passing init="... wich was helpfulless.

After that, we tryied to load the old kernels, but for a surprise of us, they started normally and after a few seconds, the log of the startup started to show a lot of messages of segmentation faults.

Now we where thinking on load the OS Using a live CD, and then try to start the service of mysql from the live CD via chroot.

So. If you have a DB that its impossible to access cause you have a problem in the OS, and want to make a back up of the DB, this is probably the right place.

This are the steps that I followed in order to start the DB:

--> Start the OS using a Live CD.
--> chroot the partition on where you used to run the OS.
--> In the chrooted partition, run: bash-3.2# /usr/bin/mysqld_safe

with this you have now (hopefully) started the mysql daemon and you can now access the DB.

now, you can just make your back ups of your DataBase:

--> on console (chrooted) run: bash-3.2# mysqldump --opt mydb > backupMyDB.sql


this will generate a backupMyDB.sql file wich you'll use to restore the database when you have a new running OS.