如何清理或调整 MySQL 中的 ibtmp1 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41216630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 22:07:17  来源:igfitidea点击:

How to clean or resize the ibtmp1 file in MySQL?

mysqldatabaseinnodbmysql-5.7

提问by Aman Aggarwal

MySQL 5.7 introduces a new file ibtmp1for storing temporary data in InnoDB to increase the performance.

MySQL 5.7 引入了一个新文件ibtmp1用于在 InnoDB 中存储临时数据以提高性能。

But I have noted that its size increases continuously. On my db server its sizes increases to 92GB.

但我注意到它的大小不断增加。在我的数据库服务器上,它的大小增加到 92GB。

Is there any way of reducing size or deleting the file without restarting the server?

有没有办法在不重新启动服务器的情况下减小文件大小或删除文件?

Thanks

谢谢

回答by Aman Aggarwal

The ibtmp1once created can't be shrink by any method without restarting mysql service.

ibtmp1一旦创建不能被任何方法而不需要重新启动mysql服务缩水。

There are two ways to handle it:

有两种处理方式:

Precaution: At the time of server start you should limit the size of this file as:

注意事项:在服务器启动时,您应该将此文件的大小限制为:

 innodb_temp_data_file_path = ibtmp1:12M:autoextend:max:5G

where max 5G means this file size limits to 5GB.

其中最大 5G 表示此文件大小限制为 5GB。

Cure: If file already created you need to restart service:

解决:如果文件已经创建,你需要重新启动服务:

SET GLOBAL innodb_fast_shutdown = 0;
Shutdown MySQL
remove ibtmp1
start MySQL.

Docs: https://dev.mysql.com/doc/refman/5.7/en/innodb-temporary-tablespace.html

文档:https: //dev.mysql.com/doc/refman/5.7/en/innodb-temporary-tablespace.html