本篇文章給大家分享的是有關(guān)mysql中怎么刪除ibdata文件,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
在數(shù)據(jù)文件下的innodb ibdata包括表空間:ibdata1,ibdata2,回滾日志ib_logfile0,ib_logfile1,ib_logfile2.
[root@localhost data]# ls
5k72 db-bin.000015 dbjijin-bin.000001 ibdata1 ib_logfile1 localhost-slow.log mysql.err test
auto.cnf db-bin.000016 dbjijin-bin.000002 ibdata2 ib_logfile2 monitor performance_schema test333
db-bin.000014 db-bin.index dbjijin-bin.index ib_logfile0 localhost.localdomain.pid mysql rrr ttt
[root@localhost data]#
現(xiàn)在刪除這幾個文件:
[root@localhost data]# rm -f ib*
[root@localhost data]# ls
5k72 db-bin.000015 dbjijin-bin.000001 localhost-slow.log mysql.err test
auto.cnf db-bin.000016 dbjijin-bin.000002 monitor performance_schema test333
db-bin.000014 db-bin.index dbjijin-bin.index localhost.localdomain.pid mysql rrr ttt
[root@localhost data]#
刪除之后,數(shù)據(jù)庫還可以正常工作,切記不要停止mysql服務(wù),不然神仙也難救.....
先找到mysql的pid.
[root@localhost data]# netstat -ntlp|grep mysqld
tcp 0 0 :::3307 :::* LISTEN 4863/mysqld
tcp 0 0 :::3306 :::* LISTEN 2169/mysqld
第一個是我們需要的pid號,4863
通過pid號,找到相關(guān)的文件,紅色標(biāo)記的是我們需要的文件:
[root@localhost data]# ll /proc/4863/fd
total 0
lr-x------. 1 root root 64 Apr 24 10:58 0 -> /dev/null
l-wx------. 1 root root 64 Apr 24 10:58 1 -> /home/mysql3307/data/mysql.err
lrwx------. 1 root root 64 Apr 24 10:58 10 -> /home/mysql3307/data/ib_logfile0 (deleted)
lrwx------. 1 root root 64 Apr 24 10:58 11 -> /home/mysql3307/data/ib_logfile1 (deleted)
lrwx------. 1 root root 64 Apr 24 10:58 12 -> /home/mysql3307/data/ib_logfile2 (deleted)
.
..
...
lrwx------. 1 root root 64 Apr 24 10:58 4 -> /home/mysql3307/data/ibdata1 (deleted)
..
...
....
lrwx------. 1 root root 64 Apr 24 10:58 9 -> /home/mysql3307/data/ibdata2 (deleted)
這時,需要暫停前端的業(yè)務(wù),也就是需要停止數(shù)據(jù)的寫操作.
關(guān)閉業(yè)務(wù),或者: flush tables with read lock;
然后把臟頁盡快刷入到磁盤里,
mysql>set global innodb_max_dirty_pages_pct=0;
然后查看binlog日志寫入情況,確保file和position的值沒有變化
Your MySQL connection id is 7
Server version: 5.6.20-log Source distribution
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| db-bin.000016 | 3415 | | | |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| db-bin.000016 | 3415 | | | |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| db-bin.000016 | 3415 | | | |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> show master status;
+---------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+------------------+-------------------+
| db-bin.000016 | 3415 | | | |
+---------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
然后查看innodb狀態(tài)信息,確保臟頁已經(jīng)刷入磁盤.
mysql> show engine innodb status \G
************************** 1. row ***************************
Type: InnoDB
Name:
Status:
=====================================
2015-04-24 11:51:52 7f7038202700 INNODB MONITOR OUTPUT
------------
TRANSACTIONS
------------
Trx id counter 18696
Purge done for trx's n:o < 18696 undo n:o < 0 state: running but idle
##確保后臺purge進(jìn)程吧 undo log 全部清除掉,事務(wù)id要一致.
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf: size 1, free list len 0, seg size 2, 0 merges
## insert buffer 合并插入緩存等于1
---
LOG
---
Log sequence number 5196495
Log flushed up to 5196495
Pages flushed up to 5196495
Last checkpoint at 5196495
## 確保這4個值不會變
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 1098907648; in additional pool allocated 0
Dictionary memory allocated 74136
Buffer pool size 65528
Free buffers 65121
Database pages 406
Old database pages 0
Modified db pages 0
## 確保臟頁數(shù)據(jù)為0
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
0 read views open inside InnoDB
Main thread process no. 1964, id 140119885477632, state: sleeping
Number of rows inserted 1, updated 0, deleted 0, read 4
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
## 確保插入,更新,刪除為0
經(jīng)過上面確認(rèn)后,可以進(jìn)行恢復(fù)操作了.復(fù)制上面表示部分?jǐn)?shù)據(jù)到數(shù)據(jù)庫目錄:
[root@localhost fd]# cp 4 /home/mysql3307/data/ibdata1
[root@localhost fd]# cp 10 /home/mysql3307/data/ib_logfile0
[root@localhost fd]# cp 11 /home/mysql3307/data/ib_logfile1
[root@localhost fd]# cp 12 /home/mysql3307/data/ib_logfile2
給文件授權(quán):
[root@localhost fd]# chown mysql:mysql /home/mysql3307/data/ib*
以上就是mysql中怎么刪除ibdata文件,小編相信有部分知識點(diǎn)可能是我們?nèi)粘9ぷ鲿姷交蛴玫降?。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道。
分享文章:mysql中怎么刪除ibdata文件-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://jinyejixie.com/article42/cshdec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、搜索引擎優(yōu)化、品牌網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容