MySQL database InnoDB engine server power down data recovery

Source: Internet
Author: User

Description

A MySQL database server on the line suddenly loses power, causing a system failure to start, and after reinstalling the system, locate the previous MySQL database folder.

Problem:

Restore the previous MySQL database by copying the file, discovering that the tables in the database could not be found when the program was called, causing the Web site to not access properly.

Analysis:

1, MySQL database, using Copy file method to restore the database, only support MyISAM engine;

2, if there is a database or data table using the InnoDB engine, the recovery, must be accompanied by the MySQL database directory ibdata1 file together with the copy.

Workaround:

1. Stop MySQL Service

Service Mysqld Stop

2. Backup database files before searching

cd/home/mysql_bak/mysql/#进入MySQL备份目录

Ibdata1 #需要此文件

3. Copy the Ibdata1 file to the corresponding directory of the database

Cp/home/mysql_bak/mysql/ibdata1/usr/local/mysql/data/ibdata1 #拷贝文件到现在的数据库目录

Chown mysql.mysql/usr/local/mysql/data/ibdata1 #设置权限位mysql用户和用户组

Rm/usr/local/mysql/data/ib_logfile0 #删除现有日志文件 or failed to start MySQL

Rm/usr/local/mysql/data/ib_logfile1 #删除现有日志文件 or failed to start MySQL

System operation and maintenance www.osyunwei.com warm reminder: system operation and maintenance of original content © Copyright, reproduced please indicate the source and the original link

4. Start MySQL

Service mysqld Start

Fault resolution

The page is now open normally.

ibdata1 function: The table data file under the InnoDB engine.

Recommendation: The database must be well backed up, the recovery of data is best used. SQL backup file Import.

At this point, the MySQL database InnoDB engine server power down data Recovery tutorial completed.

MySQL database InnoDB engine server power down data recovery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.