Home Database Mysql Tutorial 生产环境 MySQL Server 核心参数的配置

生产环境 MySQL Server 核心参数的配置

Jun 07, 2016 pm 05:28 PM

⑴ lower_case_table_names ● 推荐理由 GNU/Linux 平台,对数据库、表、存储过程等对象名称大小写敏感 为减少开发人员的开发成本

⑴ lower_case_table_names

● 推荐理由

GNU/Linux 平台,对数据库、表、存储过程等对象名称大小写敏感

为减少开发人员的开发成本,为此推荐大家设置该参数使对象名称都自动转换成小写

● 参数介绍

取值范围:

为0:区分大小写、Linux 平台默认值

为1:不区分大小写

Linux安装的MySQL的配置文件中(/etc/my.cnf)、是没有lower_case_table_names=1这行的

在Windows安装的MySQL的配置文件中(my.ini)、是有lower_case_table_names=1这行的

所以、特别提醒下、在 Replication 配置下、Master和Slave中该参数应当保持一致!!

⑵ max_connect_errors

● 推荐理由

一台物理服务器只要连接 MySQL 数据库服务器 异常中断累计超过10次,就再也无法连接上mysqld服务

为此建议大家设置此值至少大于等于10

处理方案有 2 :

要么重启mysqld、要么 mysqladmin flush-hosts

● 参数介绍

不过、该参数和安全相关、

某些黑客或许会尝试失败来暴力破解密码、该值如若设置过大会留下可趁之际

⑶ interactive_timeout和wait_timeout

● 推荐理由

如果你的MySQL Server有大量的闲置连接,他们不仅会白白消耗内存,而且如果连接一直在累加

那么、最终肯定会达到MySQL Server的连接上限数,这会报'too many connections'的错误

推荐值:

inactive_timeout=172800

wait_timeout=172800

● 参数介绍

interactive_timeout

参数含义:服务器关闭交互式连接所等待的秒数

wait_timeout

参数含义:服务器关闭非交互式连接所等待的秒数

⑷ transaction-isolation和binlog-format

推荐配置

▼只读为主的业务应用场景

transaction-isolation=read-commited

binlog-format=mixed

▼非只读为主的业务应用场景

transaction-isolation=repeatabled-read

binlog-format=mixed

⑸ innodb_adaptive_hash_index

● 推荐理由

InnoDB引擎会根据数据的访问频繁度,把表的数据逐渐缓到内存,若是一张表的数据大量缓存在内存中

则使用 HASH Index 会更高效

InnoDB内有Hash Index机制,监控数据的访 问情况,可以自动创建和维护一个Hash Index

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

Reduce the use of MySQL memory in Docker

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

How do you alter a table in MySQL using the ALTER TABLE statement?

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

How to solve the problem of mysql cannot open shared library

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

Run MySQl in Linux (with/without podman container with phpmyadmin)

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

What is SQLite? Comprehensive overview

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

Running multiple MySQL versions on MacOS: A step-by-step guide

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? Mar 18, 2025 pm 12:00 PM

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

How do I configure SSL/TLS encryption for MySQL connections?

See all articles