Innodb每个表空间一个文件

Innodb每个表空间一个文件

我正在进入一个使用 MySQL 和 Innodb 作为存储引擎的环境。我想启用 innodb_file_per_table 来提高性能。考虑到所有数据库/表当前都存储在 ibdata1/default ibdata 文件中,innodb_file_per_table 选项是否只会影响我设置此指令后创建的新表?

利用现有数据库并将每个表拆分为自己的 ibd 文件的最佳方法是什么?我是否必须转储/恢复所有表才能实现此目的?

答案1

http://dev.mysql.com/doc/refman/5.0/en/innodb-multiple-tablespaces.html

The --innodb_file_per_table option affects only table creation, not access to 
existing tables. If you start the server with this option, new tables are 
created using .ibd  files, but you can still access tables that exist in the 
shared tablespace. If you start the server without this option, new tables are 
created in the shared tablespace, but you can still access any tables that were
created using multiple tablespaces.

是的,需要转储和恢复才能将现有表移动到其自己的文件中。

答案2

我同意@faker的回答和评论(他的回答+1),但还有一件重要的事情要做:

在关闭 mysql 之前,您需要运行SET GLOBAL innodb_fast_shutdown = 0;。为什么?

这将彻底清除 ib_logfile0 和 ib_logfile1 中遗留的所有事务信息。关闭时间会更长,但对于未提交的事务数据而言,不会有任何影响。因此,在此过程中不会丢失任何数据。

以下是我在 StackOverflow 上发布的关于如何操作的帖子:https://stackoverflow.com/a/4056261/491757

相关内容