In daily work, because I am not familiar with the InnoDB engine, many people in the group have mistakenly deleted InnoDBibdata (data files) and ib_logfile (redolog redo transaction log files ), the result is a cup. For example
In daily work, because I am not familiar with the InnoDB engine, many people in the group have mistakenly deleted InnoDBibdata (data files) and ib_logfile (redolog redo transaction log files ), the result is a cup. For example
In daily work, because I am not familiar with the InnoDB engine, many people in the group have mistakenly deleted InnoDB ibdata and ib_logfile (redo log redo transaction log files ), the result is a cup. If you have master-slave replication and synchronization, it's okay. What if it's a single machine? How to restore?
See the restoration demo for the Hong Kong server below:
1. You can use sysbench to simulate Data Writing, for example:
2. rm-f ib *
3. At this time, I guess you are scared and have a trembling face. If you see this article, your mind will be stable and you will be able to recover.
4. At this time, you will find that the database can still work normally and data can still be written. Remember, do not kill the mysqld process at this time; otherwise, you will only have to skip the building and the gods will not be able to save you.
5. First find the mysqld process pid
# Netstat-ntlp | grep mysqld
Tcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN 30426/mysqld
Here I am 30426
6. Key Steps
10, 11, 4, and 9 are the files to be restored.
7. You can disable the front-end service or execute flush tables with read lock. This step prevents the database from being written for subsequent recovery.
8. How can I verify that no write operation is performed? Take the following steps for US space. Remember to observe them together.
# Refresh the dirty pages to the disk as soon as possible.
9. After the above series of validation work is completed, we can recover. Do you still remember the deleted files we recorded just now?
Copy these files to the original directory and modify user attributes.
And modify user attributes
# Cd/u2/mysql/data/
# Chown mysql: mysql ib *
10. All you can do is restart MySQL.
/Etc/init. d/mysql restart
How? It's that simple. You can also try it.
This article is from the "hechun's technical column" blog, the U.S. server, please be sure to keep this source