mysql有一些設置在重啟服務器的時候是很有必要添加的。
如:最大連接數(shù)(max_connections),最大包大小(max_allowed_packet)烙无,默認編碼格式,以及sql_mode
以下為一個我個人比較常用的mysql配置文件
當然后面部分標注了更新的內(nèi)容是我后面遇到實際問題添加的一些參數(shù)遍尺,所以沒有寫的太具體截酷。
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
character-set-server = utf8 #設置默認編碼utf8
#
# 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 = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
log_bin=mysql-bin
expire_logs_days=7
server_id=1
#開啟登錄時記錄相關(guān)登錄信息
init-connect='insert into accesslog.accesslog(id, time, localname, matchname) values(connection_id(),now(),user(),current_user());'
#
# 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 = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/data/mysql #設置數(shù)據(jù)存儲路徑
socket=/var/lib/mysql/mysql.sock
max_allowed_packet = 66M #設置最大包大小
max_connections=10000 #設置最大連接數(shù)
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#設置默認編碼utf8
[mysql]
default-character-set = utf8
[mysql.server]
default-character-set = utf8
[mysqld_safe]
default-character-set = utf8
[client]
default-character-set = utf8
#更新
#如果在創(chuàng)建函數(shù)的時候報錯(deterministic ,nosql,read sql)
#可以添加以下內(nèi)容重啟服務器
log_bin_trust_function_creators=1
#更新
sql update 安全模式
SET GLOBAL SQL_SAFE_UPDATES = 1;
#更新
對于大表:
innodb_data_file_path設置autoextend
加大
tmp_table_size 臨時表大小設置,不要過大
max_heap_table_size 最大內(nèi)存表設置乾戏,不要過大
#更新
group_concat_max_len = 200000
concat函數(shù)
#服務器相關(guān)優(yōu)化
query_cache_size:用于緩存查詢的內(nèi)存大小
table_cache:mysql同一時間內(nèi)保持大開的table的數(shù)量
#存儲引擎相關(guān)優(yōu)化
innodb_buffer_pool_size 緩沖池字節(jié)大小
MySQL5.7.5對于Buffer的分配需要提前計算一下合搅。 盡量讓
innodb_buffer_pool_size= innodb_buffer_pool_chunk_size * innodb_buffer_pool_instances
從而獲取一個較佳的性能多搀。
innodb_buffer_pool_chunk_size默認是128M.
innodb_log_buffer_size 寫入日志文件緩沖字節(jié)數(shù)
innodb_log_file_size 每個日志文件字節(jié)大小