MySQL mistakenly delete innodb data file recovery

Source: Internet
Author: User

Error Recurrence:

use rm-f ib* to delete data files and redo log files.

At this MySQL process also exists, MySQL can also be used normally.

File Recovery:

1 : Find mysqld the process number.

# NETSTAT-NTPL | grep mysqld TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 12147/mysqld


2: Use the process number to find the following file.

# LL/PROC/12147/FD | Egrep ' Ib_|ibdata ' lrwx------1 root root, 09:23/mydata/ib_logfile1 (deleted) lrwx------1 root root June 09:23 4-/mydata/ibdata1 (deleted) lrwx------1 root root June 09:23 9-/mydata/ib_logfile0 (Del eted)

3: Add a lock so that the database does not have write operations.

Sql> flush tables with read lock;

4: Enter the following command to have the dirty page brush into the disk as soon as possible.

sql> set global innodb_max_dirty_pages_pct=0;

5: Check the InnoDB status information, verify that the dirty page has been brushed into the disk, compared to the following values:

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/83/CE/wKiom1d8xOaD0CiyAAMcq5xJP7Q778.jpg "style=" float: none; "title=" 1.jpg "alt=" Wkiom1d8xoad0ciyaamcq5xjp7q778.jpg "/>

650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M01/83/CD/wKioL1d8xOnCp__oAAPycmf52lE458.jpg "style=" float: none; "title=" 2.jpg "alt=" Wkiol1d8xoncp__oaapycmf52le458.jpg "/>

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M01/83/CE/wKiom1d8xOvga9oyAANGMuf7h74073.jpg "style=" float: none; "title=" 3.jpg "alt=" Wkiom1d8xovga9oyaangmuf7h74073.jpg "/>


6: After the confirmation is completed, the recovery operation can be done, and the previously recorded deleted files are copied to the original directory.

# CD/PROC/12147/FD # CP 10/mydata/ib_logfile1# CP 4/mydata/ibdata1# CP 9/MYDATA/IB_LOGFILE0

7: Restart mysqld service is available.


This article from the "Play God Clown" blog, reproduced please contact the author!

MySQL mistakenly delete innodb data file recovery

Related Article

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.