MySQL database InnoDB engine server power-off data recovery method, mysqlinnodb
Note:
An online MySQL database server suddenly loses power, causing system failure to start up. After you reinstall the system, find the previous MySQL database folder.
Problem:
By copying files to restore the previous MySQL database, we found that the table in the database could not be found during Program Calling, resulting in the website being inaccessible.
Analysis:
1. MySQL database, which uses the copy file method to restore the database, only supports the MyISAM engine;
2. If a database or data table uses the InnoDB engine, it must be copied together with the ibdata1 file in the MySQL database directory during restoration.
Solution:
1. Stop the MySQL Service
Service mysqld stop
2. Find the backup database file
Cd/home/mysql_bak/mysql/# enter the MySQL Backup Directory
Ibdata1 # This file is required
3. Copy the ibdata1 file to the corresponding database directory.
Cp/home/mysql_bak/mysql/ibdata1/usr/local/mysql/data/ibdata1 # copy the file to the current database directory
Chown mysql. mysql/usr/local/mysql/data/ibdata1 # Set the permission limit for mysql users and user groups
Rm/usr/local/mysql/data/ib_logfile0 # Delete existing log files; otherwise, MySQL cannot be started.
Rm/usr/local/mysql/data/ib_logfile1 # Delete existing log files; otherwise, MySQL startup fails.
4. Start MySQL
Service mysqld start
Troubleshooting
The page is opened normally.
Ibdata1: Table data files under the InnoDB engine.
Suggestion: the database must be backed up. It is best to use the. SQL backup file for data recovery.
At this point, the MySQL database InnoDB engine server power-off data recovery tutorial is complete.