Mysql database InnoDB engine server power off data recovery method _mysql

Source: Internet
Author: User

Description

A MySQL database server on the line suddenly power off, causing system failure to start, reinstall the system, locate the MySQL database folder before.

Problem:

By copying files to the previous MySQL database recovery, found in the program call can not find the table in the database, resulting in the Web site is not normal access.

Analysis:

1, MySQL database, the use of copy files to restore the database, only support MyISAM engine;
2, if there is a database or data table using the InnoDB engine, restore, must be accompanied by the MySQL database directory with the ibdata1 file to copy over.

Solution:

1. Stop MySQL Service

Service Mysqld Stop

2, to find the previous backup database files

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

Ibdata1 #需要此文件

3, copy ibdata1 files 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 #删除现有日志文件, otherwise start MySQL failed
Rm/usr/local/mysql/data/ib_logfile1 #删除现有日志文件, otherwise start MySQL failed


4. Start MySQL

Service mysqld Start

Fault resolution

The page is now open normally.

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

Recommendation: Database must do a good backup, restore data is best to use. SQL backup file Import.

At this point, the MySQL database InnoDB engine under the server Outage Data Recovery tutorial completed.

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.