1G内存VPS环境下,如何优化MySQL 5.6内存参数

很早就听说MySQL 5.6版本比较占内存,必须要在1G内存可以成功安装,所以服务器一直是5.5版本。前几天,发现Wordpress系统推荐使用php7.3和MySQL5.6,而我的Vultr VPS的环境配置还是php 7.2 和MySQL5.5,想着好久没折腾了,今天就升级了下版本。

MySQL 5.6优化

安装5.6版本,最好配置下1G大小的SWAP区。如果觉得内存占用很高,可以修改performance_schema_max_table_instances、table_definition_cache、table_open_cache、performance_schema这个三个参数。

MySQL5.6默认值如下
performance_schema_max_table_instances 12500
table_definition_cache 1400
table_open_cache 2000

参数含义:
performance_schema_max_table_instances :The maximum number of instrumented table objects.
table_definition_cache:The number of table definitions (from .frm files) that can be stored in the definition cache
table_open_cache:The number of open tables for all threads.
对于小网站,最大连接数设定为 100 到 300 左右;而较为大型的网站可能需要 500 到 800,甚至更多。
MySQL 5.6默认启用performance_schema,占用很多内存,可以禁用。

MySQL 5.6优化参数


performance_schema_max_table_instances = 300
table_definition_cache = 200
table_open_cache = 128
performance_schema = OFF

1G内存VPS环境下,如何优化MySQL 5.6内存参数》有4个想法

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注