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.