Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mysql ibdata file erroneous deletion recovery

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1 when we mistakenly delete the ibdata file

Do not panic at this time as long as you do not restart the service mysql database can still be used

How to recover

Premise

Do not kill the mysqld process, and do not shut down the mysql service

Found mysqld's pid.

[mysql@mvxl0782 binlog] $netstat-nltp | grep mysqld

(Not all processes could be identified, non-owned process info

Will not be shown, you would have to be root to see it all.)

Tcp 0 0: 3306: * LISTEN 18401/mysqld

This is 18401.

two。 Use process pid to view the corresponding file descriptor

[mysql@mvxl0782 binlog] $ll / proc/18401/fd | egrep 'ib_ | ibdata'

Lrwx- 1 mysql mysql 64 August 11 10:33 10-> / mysql/server/data/ib_logfile1

Lrwx- 1 mysql mysql 64 August 11 10:33 11-> / mysql/server/data/ib_logfile2

Lrwx- 1 mysql mysql 64 August 11 10:33 4-> / mysql/server/data/ibdata1

Lrwx- 1 mysql mysql 64 August 11 10:33 9-> / mysql/server/data/ib_logfile0

The above 10, 11, 4 and 9 are the files we want to recover.

3. Close the front-end business or execute flush tables with read lock; to prevent data from being written.

4. Verify whether any data has been written

a. Type the following command to write the dirty page to disk as soon as possible

Set global innodb_max_dirty_pages_ptc=0

b. Check binlog log writes to make sure that file and position do not change show master status

c. Finally, check the innodb status information to make sure that the dirty page has been brushed into the disk.

Show engine inndodb status\ G

TRANSACTIONS

.

Trx id counter A21837

Purge don for trx's n:o / mysql/server/data/ib_logfile2

Lrwx- 1 mysql mysql 64 August 11 10:33 4-> / mysql/server/data/ibdata1

Lrwx- 1 mysql mysql 64 August 11 10:33 9-> / mysql/server/data/ib_logfile0

Copy and rename the above file:

Cp 10 / mysql/server/data/ib_logfile1

Cp 11 / mysql/server/data/ib_logfile2

Cp 4 / mysql/server/data/ibdata1

Cp 9 / mysql/server/data/ib_logfile0

Authorization:

Cd / mysql/server/data

Chown-R mysql:dba ib*

Finally restart mysql

Transferred from http://blog.csdn.net/zengxuewen2045/article/details/52333383

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report