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

How to delete ibdata ib_logfile and other files in Mysql by mistake?

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the Mysql mistakenly deleted ibdata ib_logfile and other files how to do, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Background: mistakenly delete ibdata and other files

[root@localhost / var/lib/mysql] # rm-rf ib*

Ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 ibtmp1

Do not panic at this time, because mysql is still running, can also operate, if you turn off mysql, then there is no way, the recovery steps are as follows

1. Turn off all business writes

Flush tables with read lock

two。 Check the pid number of mysql

[root@localhost / var/lib/mysql] # ps-ef | grep-I mysql

Root 386 10 May06? 00:00:00 / bin/sh / usr/local/mariadb/bin/mysqld_safe-- defaults-file=/usr/local/mariadb/my.cnf

Mysql 491 3860 May06? 00:16:13 / usr/local/mariadb/bin/mysqld-- defaults-file=/usr/local/mariadb/my.cnf-- basedir=/usr/local/mariadb-- datadir=/usr/local/mariadb/demo-- plugin-dir=/usr/local/mariadb/lib/plugin-- user=mysql-- log-error=/usr/local/mariadb/demo/mardb.err-pid-file=/usr/local/mariadb/demo/mardb.pid-- socket=/usr/local/mariadb/demo/mardb.socket-- port=3333

Root 14790 10 14:06? 00:00:00 / bin/sh / usr/bin/mysqld_safe-- datadir=/var/lib/mysql-- socket=/var/lib/mysql/mysql.sock-- pid-file=/var/run/mysqld/mysqld.pid-- basedir=/usr-- user=mysql

Mysql 15010 14790 0 14:06? 00:00:05 / usr/sbin/mysqld-basedir=/usr-datadir=/var/lib/mysql-plugin-dir=/usr/lib64/mysql/plugin-user=mysql-log-error=/var/log/mysqld.log-pid-file=/var/run/mysqld/mysqld.pid-socket=/var/lib/mysql/mysql.sock

Root 18180 17974 0 15:03 pts/3 00:00:00 grep-I mysql

[root@localhost / var/lib/mysql] # netstat-nputl | grep-I mysql

Tcp 0 0: 3333: * LISTEN 491/mysqld

Tcp 0 0: 3306: * LISTEN 15010/mysqld

3 enter the virtual directory proc that comes with the linux system to see if the file still exists

[root@localhost / var/lib/mysql] # ll / proc/15010/fd | grep-I 'ib'

Lrwx- 1 root root 64 May 12 15:03 10-> / var/lib/mysql/ibtmp1 (deleted)

Lrwx- 1 root root 64 May 12 15:03 3-> / var/lib/mysql/ibdata1 (deleted)

Lrwx- 1 root root 64 May 12 15:03 8-> / var/lib/mysql/ib_logfile0 (deleted)

Lrwx- 1 root root 64 May 12 15:03 9-> / var/lib/mysql/ib_logfile1 (deleted)

4. Enter the command to refresh the dirty fast to the disk.

Mysql > set global innodb_max_dirty_pages_pct=0

5 make sure that binlog pos and file remain the same

Mysql > show master status

+-- +

| | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | |

+-- +

| | mysql-bin.000176 | 449250839 | 6c8a10ed-ed0b-11e4-91eb-00163ec546ca:1-212063619 | |

+-- +

1 row in set (0.00 sec)

6. View the information of engine innodb

Such as:

Mysql > show engine innodb status\ G

* * 1. Row *

Type: InnoDB

Name:

Status:

= =

2016-05-12 15:25:55 0x7f7692d0e700 INNODB MONITOR OUTPUT

= =

Per second averages calculated from the last 10 seconds

-

BACKGROUND THREAD

-

Srv_master_thread loops: 35 srv_active, 0 srv_shutdown, 585 srv_idle

Srv_master_thread log flush and writes: 620

-

SEMAPHORES

-

OS WAIT ARRAY INFO: reservation count 17

OS WAIT ARRAY INFO: signal count 15

RW-shared spins 0, rounds 63, OS waits 6

RW-excl spins 0, rounds 11, OS waits 0

RW-sx spins 0, rounds 0, OS waits 0

Spin rounds per wait: 63.00 RW-shared, 11.00 RW-excl, 0.00 RW-sx

-

TRANSACTIONS

-

Trx id counter 3625

Purge done for trx's n:o

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