「MySQL」- 配置优化

  CREATED BY JENKINSBOT

内容:介绍MySQL配置优化。

当正确把MySQL的基本项配置之后,剩下的主要精力要放在查询、索引等方面的优化。
不要配置当作救命稻草。有些特殊配置确实可以显著提升性能,但是这些配置不能作为基本配置。
如果你不懂,就不要去配置。更不要到网上搜索配置。

配置文件的位置

#!/bin/sh

mysql --help | grep -A 1 'Default options'
# 输出:
# Default options are read from the following files in the given order:
# /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

# 如上,/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf 是配置文件的位置。

这篇文章根本不值得一读。

[mysqld]
# GENERAL
datadir 						= /var/lib/mysql
socket 							= /var/lib/mysql/mysql.sock
pid_file 						= /var/lib/mysql/mysql.pid
user							= mysql
port 							= 3306
default_storage_engine			= InnoDB

# InnoDB
innodb_buffer_poll_size			= <>
innodb_log_file_size			= <>
innodb_file_per_table			= 1
innodb_flush_method				= O_DIRECT

# MyISAM
key_buffer_size					= <>

# LOGGING
log_error 						= /var/lib/mysql/mysql-error.log
slow_query_log					= /var/lib/mysql/mysql-slow.log

# OTHER
tmp_table_size					= 32M
max_heap_table_size				= 32M
query_cache_type				= 0
query_cache_size				= 0
max_connections					= <>
thread_cache					= <>
table_cache						= <>
open_files_limit				= 65535

[client]
socket							= /var/lib/mysql/mysql.sock
port 							= 3306