How to recover MySQL when the HDD on an older Linux server fails

table of contents
This is Haraoka from Beyond
We have put together a simple summary of the steps to recover not only data files but also MySQL data when your old server will no longer boot due to hard disk damage
This guide will show you how to recover data from MySQL 3.23.58.
*Please note that data recovery involves various factors, so this guide is for reference only.*
Have your data recovered by a hard disk recovery company
First, you need to restore the failed HDD
It may be possible to recover the data yourself as described below, but if you fail, the situation may worsen, so if the data contains business data or other data, it is best to use a hard disk recovery service to ensure the data is recovered as reliably as possible
How to repair and recover data from an HDD, even for amateurs:
http://macasakr.sakura.ne.jp/HDD
There are many different companies out there, but my recommendation is Kumanan PC Net.
https://www.kumanan-pcnet.co.jp/hdd/info.php
In fact, there are significant differences in technical ability among companies, but Kumanan PC Net has 15 years of experience, has its own clean room, and provides recovery services based on high technical skills
Build a recovery server
- Preparing the server for building
We will prepare a suitable chassis and build a server for database recovery. First, we will check the OS version of the server on which MySQL was running
cat /recovery_directory/etc/redhat-release
in the directory of the recovered data
check the `redhat-release` file
Older operating systemsi386ori686 processors. While it's possible to install a 32-bit OS on a 64-bit CPU, it will only recognize up to 4GB of memory, so it's best to remove any excess memory from cases with a larger configuration.
- Installing an older version of Linux OS
This time, I'm using CentOS as a reference:
http://www.linuxmaster.jp/linux_blog/2010/03/centos.html
Download it from this site:
http://vault.centos.org/
This is a great site where you can download CentOS 2.1 and later.
This time, I downloaded CentOS 4.
Download MySQL
I borrowed the installation files from here:
http://dbstudy.info/mysql/
It's also available here:
http://live.dadanini.at/mysql/downloads_html/mysql-3.23.html
Install MySQL
Build from source files
- Creating the installation directory and user
cd /usr/local/src/ /usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql mkdir /usr/local/mysql mkdir /usr/local/mysql/var/ chown -R mysql:mysql /usr/local/mysql
- Installing MySQL
tar -zxvf mysql-3.23.58.tar.gz cd mysql-3.23.58/ ./configure --prefix=/usr/local/mysql make make install
- Creating an installation database
scripts/mysql_install_db
- mysql start
/usr/local/mysql/bin/safe_mysqld --user=mysql &
*Please note that this is not mysqld_safe
- Startup check
ps -ef | grep mysql
- Try logging in (no password)
mysql -u root
- Set the root password
mysqladmin -u root password "*****"
- mysql stop
/usr/local/mysql/bin/mysqladmin -u root -p shutdown
Now you're ready to restore
Replace the recovered data file
Upload the entire MySQL data file from the HDD recovery destination
There is a possibility that the characters may be garbled, so it is better to compress and move the file if possible
- Unzip the uploaded file
gunzip /home/hogehoge/mysql_buckupdata.gz
- Move entire directory of data files
mv /usr/local/mysql/var /usr/local/mysql/var_tmp cp /home/hogehoge/mysql_buckupdata /usr/local/mysql/var
- Permission Change
chown -R mysql:mysql /usr/local/mysql/var
- Delete iblogfile
rm /usr/local/mysql/var/ib_logfile*
- Starting the DB
mysql start/stop
/usr/local/mysql/bin/mysqld_safe --user=mysql &
If it starts up like this, recovery is OK for now
Exporting the DB
mysqldump -u root -p db name > /home/hogehoge/new_buckup.dmp
Export the recovered data
This completes the data recovery
If you have any problems with recovery, please contact Beyond
https://beyondjapan.com/contact
0
