[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

How to recover MySQL when the HDD of an old version of Linux server fails

This is Haraoka from Beyond.

We have summarized the steps to easily recover not only data files but also MySQL data when an old server cannot start due to hard disk corruption.

This time we will recover MySQL 3.23.58 data.
*Data recovery depends on various factors, so please use this information as a reference only.

Have a hard disk recovery company restore your data.

First of all, you need to recover the failed HDD.

There are some cases where you can restore the hard disk yourself as shown below, but if you fail, the situation may worsen, so if you have business data, etc., it is better to use a hard disk recovery company to ensure the most reliable recovery. I think so.

HDD repair and recovery methods that even amateurs can do
http://macasakr.sakura.ne.jp/HDD

There are quite a few 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 is a considerable difference in technical ability among the companies, but Kumanan PC Net has a 15-year track record, has its own clean room, and can handle recovery based on its high level of technical ability.

Build a recovery server

  • Prepare the server for construction

We will prepare a suitable chassis and build a server for database recovery. First, check the OS version of the server where MySQL was running.

1
cat /recovery directory/etc/redhat-release


check the redhat-release file in the directory of the recovered data


The older OS may be a 32-bit version such as i386 or i686 You can install a 32-bit version of the OS on a 64-bit CPU, but it can only recognize up to 4GB of memory, so it is better to remove the chassis that has a large amount of memory.

  • Install an older version of LinuxOS

This time I will use CentOS as a reference from this site
http://www.linuxmaster.jp/linux_blog/2010/03/centos.html

Download from this site.
http://vault.centos.org/The
above site is a great site where you can download CentOS2.1 or later.
This time I downloaded CentOS4 series.

Download MySQL

Borrow the installation file from here
http://dbstudy.info/mysql/

It's also here.
http://live.dadanini.at/mysql/downloads_html/mysql-3.23.html

Install MySQL

Build from source files.

  • Creating an installation directory and user
1
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
1
tar -zxvf mysql-3.23.58.tar.gz cd mysql-3.23.58/ ./configure --prefix=/usr/local/mysql make make install
  • Creation of installation DB
1
scripts/mysql_install_db
  • mysql start
1
/usr/local/mysql/bin/safe_mysqld --user=mysql &

*Please note that it is not mysqld_safe.

  • Startup confirmation
1
ps -ef | grep mysql
  • Try logging in (no pass)
1
mysql -u root
  • Setting root password
1
mysqladmin -u root password "*****"
  • mysql stop
1
/usr/local/mysql/bin/mysqladmin -u root -p shutdown

Now you are ready for recovery

Replace recovered data files

Upload the entire MySQL data file from the recovered HDD

There is also the possibility of garbled characters, so it is better to compress and move if possible.

  • Unzip the uploaded file
1
gunzip /home/hogehoge/mysql_buckupdata.gz
  • Move the entire data file directory
1
mv /usr/local/mysql/var /usr/local/mysql/var_tmp cp /home/hogehoge/mysql_buckupdata /usr/local/mysql/var
  • Change permissions
1
chown -R mysql:mysql /usr/local/mysql/var
  • Delete iblogfile
1
rm /usr/local/mysql/var/ib_logfile*
  • Start DB

mysql start/stop

1
/usr/local/mysql/bin/mysqld_safe --user=mysql &

If you start it now, recovery is OK for now.

Export DB

1
mysqldump -u root -p db name > /home/hogehoge/new_buckup.dmp

Export the recovered data

This completes the data recovery.

If you have any trouble with recovery, please contact Beyond.

https://beyondjapan.com/contact

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
923
X facebook Hatena Bookmark pocket
[2026.6.30 Amazon Linux 2 end of support] Amazon Linux server migration solution

[2026.6.30 Amazon Linux 2 end of support] Amazon Linux server migration solution

The person who wrote this article

About the author

Masahiro Haraoka

I am the representative director of Beyond Co., Ltd.

Oracle DBA (taking care of DB on UNIX, Linux, Windows Sever)
⇒Linux engineer (constructing and operating servers, FW, L3, etc. in DC)
⇒Cloud engineer (multi-cloud AWS, GCP, Azure, etc.)
⇒Manager

My hobby is reading. I read everything, including manga, online novels, and business books. I recently started solo camping.