在线精品99_中国九九盗摄偷拍偷看_91免费版在线观看_91.app_91高清视频在线_99热最新网站

mysql中怎么删除ibdata文件

108次阅读
没有评论

共计 5114 个字符,预计需要花费 13 分钟才能阅读完成。

本篇文章给大家分享的是有关 mysql 中怎么删除 ibdata 文件,丸趣 TV 小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着丸趣 TV 小编一起来看看吧。

在数据文件下的 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]#

现在删除这几个文件:

[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]#

删除之后, 数据库还可以正常工作, 切记不要停止 mysql 服务, 不然神仙也难救 …..

先找到 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 号, 找到相关的文件, 红色标记的是我们需要的文件:
[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)

这时, 需要暂停前端的业务, 也就是需要停止数据的写操作.
关闭业务, 或者: 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 状态信息, 确保脏页已经刷入磁盘.
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 进程吧 undo log 全部清除掉, 事务 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
## 确保脏页数据为 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

经过上面确认后, 可以进行恢复操作了. 复制上面表示部分数据到数据库目录:
[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
给文件授权:
[root@localhost fd]# chown mysql:mysql /home/mysql3307/data/ib*

以上就是 mysql 中怎么删除 ibdata 文件,丸趣 TV 小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注丸趣 TV 行业资讯频道。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-08-04发表,共计5114字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)
主站蜘蛛池模板: 国产超薄肉色丝袜的免费网站 | 日本-区二区三区免费精品 日本全黄录像视频 | 日本少妇xxx做受 | 黄色在线视频播放 | 久草视频免费在线 | 美女丝袜在线观看 | 久久精品私人影院免费看 | 人人妻人人添人人爽欧美一区 | 日本亚洲中文字幕不卡 | 久久综合琪琪狠狠天天 | 亚洲日韩中文无码久久 | 人妻中文无码久热丝袜 | 国产精品偷窥熟女精品视频 | 国产精品99久久精品爆乳 | 免费黄动漫在线观看 | 亚洲国产精品一区二区www | 亚洲一区二区三区精品国产 | 成在人线无码aⅴ免费视频 成在线人免费视频 | 日本一本在线 | h视频在线免费 | 久久久久久九九99精品 | 人妻精品无码一区二区三区 | 久久性生活视频 | 久草在线手机 | 天躁夜夜躁狼狠躁 | 天天做天天爱天天综合网 | 亚洲爆乳www无码专区 | 欧美精品一区二区精品久久 | 欧美精品国产精品 | 午夜裸体性播放 | 99久热只有精品视频免费看 | 在线播放免费播放av片 | 91久久精品一区二区三区 | 97视频在线观看播放 | 人妻熟妇乱又伦精品视频 | 国产av电影区二区三区曰曰骚网 | 国产无遮挡18禁网站免费 | 日本中文字幕一区二区有码在线 | 黄色毛片免费观看 | 亚洲性人人天天夜夜摸 | 亚洲午夜理论片在线观看 |