最佳MySQL配置(my.cnf) [英] Optimal MySQL-configuration (my.cnf)
问题描述
以下是我的默认生产MySQL配置文件(my.cnf
),用于将InnoDB作为默认存储引擎的纯UTF-8设置.
[server]
bind-address=127.0.0.1
innodb_file_per_table
default-character-set=utf8
default-storage-engine=innodb
安装程序执行以下操作:
- 绑定到localhost:3306(环回),而不是默认的*:3306(所有接口).完成以提高安全性.
- 为每个表设置一个表空间.完成以提高可维护性.
- 将默认字符集设置为UTF-8.完成此操作后,默认情况下即可轻松实现国际化.
- 将默认存储引擎设置为InnoDB.完成以默认情况下允许行级锁定.
假设您可以通过最多添加三(3)个配置参数来进一步改善设置.您要添加哪个?为什么?
在这种情况下,改进将意味着性能提高,可靠性提高或易用性/易维护性的提高.您可以假定运行MySQL实例的计算机将具有1000 MB的RAM.要缓存更多数据:
innodb_buffer_pool_size = 512M
如果您写入大量数据:
innodb_log_file_size = 128M
,以避免过多的日志切换.
在任何情况下,我都不会添加第三位,所有其他情况都取决于此.
The following is my default production MySQL configuration file (my.cnf
) for a pure UTF-8 setup with InnoDB as the default storage engine.
[server]
bind-address=127.0.0.1
innodb_file_per_table
default-character-set=utf8
default-storage-engine=innodb
The setup does the following:
- Binds to localhost:3306 (loopback) instead of the default *:3306 (all interfaces). Done to increase security.
- Sets up one table space per table. Done to increase maintainability.
- Sets the default character set to UTF-8. Done to allow for easy internationalization by default.
- Sets the default storage engine to InnoDB. Done to allow for row-level-locking by default.
Assume that you could further improve the setup by adding a maximum of three (3) configuration parameters. Which would you add and why?
An improvement would in this context mean either a performance improvement, a reliability improvement or ease-of-use/ease-of-maintainability increase. You can assume that the machine running the MySQL instance will have 1000 MB of RAM.
To cache more data:
innodb_buffer_pool_size = 512M
If you write lots of data:
innodb_log_file_size = 128M
, to avoid too much log switching.
There is no third I'd add in any case, all other depend.
这篇关于最佳MySQL配置(my.cnf)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!