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.
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
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
- Creation of installation DB
scripts/mysql_install_db
- mysql start
/usr/local/mysql/bin/safe_mysqld --user=mysql &
*Please note that it is not mysqld_safe.
- Startup confirmation
ps -ef | grep mysql
- Try logging in (no pass)
mysql -u root
- Setting root password
mysqladmin -u root password "*****"
- mysql stop
/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
gunzip /home/hogehoge/mysql_buckupdata.gz
- Move the entire data file directory
mv /usr/local/mysql/var /usr/local/mysql/var_tmp cp /home/hogehoge/mysql_buckupdata /usr/local/mysql/var
- Change permissions
chown -R mysql:mysql /usr/local/mysql/var
- Delete iblogfile
rm /usr/local/mysql/var/ib_logfile*
- Start DB
mysql start/stop
/usr/local/mysql/bin/mysqld_safe --user=mysql &
If you start it now, recovery is OK for now.
Export 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 trouble with recovery, please contact Beyond.
https://beyondjapan.com/contact