MySQL 5.6 my.cnf 配置优化
升级服务器后一早打开自己的博客是打不开的... 提示太多连接数据库. 看来升级后一样逃脱不了要折腾一段时间的魔咒. 磨合期 优化了一下 Mysql 的 my.cnf 文件 参考了这篇文章:https://blog.imdst.com/mysql-5-6-pei-zhi-you-hua/
本来是直接复制进去的 几次都是无法启动 最后自己调整了下使用 我的 vps 是 2g 内存的 配置文件如下
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/ ... ation-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 8M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 8M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-bin
skip-networking
default-time-zone = '+8:00'
performance_schema_max_table_instances=200
table_definition_cache=200
table_open_cache=128
open_files_limit = 10240
back_log = 600
max_connections = 3000
max_connect_errors = 6000
external-locking = FALSE
max_allowed_packet = 32M
thread_cache_size = 300
query_cache_size = 64M
query_cache_limit = 4M
query_cache_min_res_unit = 2k
tmp_table_size = 256M
expire_logs_days = 7
read_buffer_size = 1M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 3G
innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 1024M
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid