亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1564 | 回復(fù): 0
打印 上一主題 下一主題

【轉(zhuǎn)】縮小mysql數(shù)據(jù)庫的ibdata1文件 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2011-12-23 01:42 |只看該作者 |倒序瀏覽

原文:http://hi.baidu.com/timework/blog/item/e07d25448cd41e2acefca321.html

ibdata1是mysql使用InnoDB引擎的時候需要使用的文件。這個文件有的時候會變得很大,并且在你刪除數(shù)據(jù)的時候,文件也不減小。今天就碰到了一次,導(dǎo)致所有的/var分區(qū)都被占用光了。


下面是處理超大ibddata1文件的步驟:

1. 對每張表使用單獨的innoDB文件, 修改/etc/my.cnf文件
[mysqld]
innodb_file_per_table

目的很明確,我們可以單獨刪除每個文件

2. 導(dǎo)出所有的數(shù)據(jù),重建數(shù)據(jù)庫,然后恢復(fù)數(shù)據(jù):
# /usr/bin/mysqldump -R -q --all-databases > /temp/all.sql
# service mysqld stop
# rm -fr /var/lib/mysql/*
# /usr/bin/mysql_install_db
# service mysqld restart
# mysql < /tmp/all.sql

3. /var/lib/mysql的每個數(shù)據(jù)庫下面,都有會很多的.ibd文件。這些分散的.ibd文件取代了原來的那個ibddata1。

以后刪除數(shù)據(jù)庫的時候,直接刪除某個數(shù)據(jù)庫的目錄就可以了。

————-華麗的分隔符————-

mysql 使用的引擎:
mysql> show engines;
+------------+---------+----------------------------------------------------------------+
| Engine | Support | Comment |
+------------+---------+----------------------------------------------------------------+
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys |
| BerkeleyDB | YES | Supports transactions and page-level locking |
| BLACKHOLE | NO | /dev/null storage engine (anything you write to it disappears) |
| EXAMPLE | NO | Example storage engine |
| ARCHIVE | NO | Archive storage engine |
| CSV | NO | CSV storage engine |
| ndbcluster | NO | Clustered, fault-tolerant, memory-based tables |
| FEDERATED | NO | Federated MySQL storage engine |
| MRG_MYISAM | YES | Collection of identical MyISAM tables |
| ISAM | NO | Obsolete storage engine |
+------------+---------+----------------------------------------------------------------+
12 rows in set (0.00 sec)
For InnoDB tables, OPTIMIZE TABLE is mapped to ALTER TABLE, which rebuilds the table to update index statistics and free unused space in the clustered index.
所以不會直接來減少ibdata的文件尺寸。
減少ibdata的方法如下

- 1. 用mysqldump等工具導(dǎo)出數(shù)據(jù) - 2. 停止 mysqld
- 3. 刪除ibdata*, ib_logfile* 文件
- 4. 重新啟動 mysqld(這時mysqld就會自動創(chuàng)建 idbdata*, ib_logfile* 文件)

- 5. 將到出來的數(shù)據(jù)導(dǎo)回去,體積才會減小。

您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP