How to recover MySQL when the HDD of an old version of 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 time we will be recovering data from MySQL 3.23.58.
*Data recovery involves various factors, so please use this information as a 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 restore your hard drive even if you're not an expert
http://macasakr.sakura.ne.jp/HDD
There are a lot of different companies out there, but the one I recommend 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
check the redhat-release file in the directory of the recovered data
Older operating systems i386 or i686 . You can install a 32-bit operating system on a 64-bit CPU, but it can only recognize up to 4GB of memory, so it's best to remove any memory that's installed in the chassis.
- Installing an older version of Linux OS
This time, I used CentOS as a reference from this site:
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.
I downloaded CentOS 4 this time.
Download MySQL
Borrow the installation file 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