首页 » Linux » mysql5.6/5.7配置文件

mysql5.6/5.7配置文件

 

总共有两份配置文件,第一份来自网上,第二份是自己的。

第一份如下:

用户只需根据自己的服务器配置稍作修改即可,如InnoDB缓冲池的大小、IO能力(innodb_buffer_pool_size,innodb_io_capacity)。特别注意,这份配置文件不用修改,可以直接运行在MySQL 5.6和5.7的版本下,这里使用了小小的技巧,具体可看配置文件

[client]
user=david
password=88888888
 
[mysqld]
########basic settings########
server-id = 11
port = 3306
user = mysql
bind_address = 10.166.224.32
autocommit = 0
character_set_server=utf8mb4
skip_name_resolve = 1
max_connections = 800
max_connect_errors = 1000
datadir = /data/mysql_data
transaction_isolation = READ-COMMITTED
explicit_defaults_for_timestamp = 1
join_buffer_size = 134217728
tmp_table_size = 67108864
tmpdir = /tmp
max_allowed_packet = 16777216
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
interactive_timeout = 1800
wait_timeout = 1800
read_buffer_size = 16777216
read_rnd_buffer_size = 33554432
sort_buffer_size = 33554432
########log settings########
log_error = error.log
slow_query_log = 1
slow_query_log_file = slow.log
log_queries_not_using_indexes = 1
log_slow_admin_statements = 1
log_slow_slave_statements = 1
log_throttle_queries_not_using_indexes = 10
expire_logs_days = 90
long_query_time = 2
min_examined_row_limit = 100
########replication settings########
master_info_repository = TABLE
relay_log_info_repository = TABLE
log_bin = bin.log
sync_binlog = 1
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
relay_log = relay.log
relay_log_recovery = 1
binlog_gtid_simple_recovery = 1
slave_skip_errors = ddl_exist_errors
########innodb settings########
innodb_page_size = 8192
innodb_buffer_pool_size = 6G
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_lru_scan_depth = 2000
innodb_lock_wait_timeout = 5
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_log_group_home_dir = /redolog/
innodb_undo_directory = /undolog/
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_flush_neighbors = 0
innodb_log_file_size = 4G
innodb_log_buffer_size = 16777216
innodb_purge_threads = 4
innodb_large_prefix = 1
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_strict_mode = 1
innodb_sort_buffer_size = 67108864
########semi sync replication settings########
plugin_dir=/usr/local/mysql/lib/plugin
plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
loose_rpl_semi_sync_master_enabled = 1
loose_rpl_semi_sync_slave_enabled = 1
loose_rpl_semi_sync_master_timeout = 5000
 
[mysqld-5.7]
innodb_buffer_pool_dump_pct = 40
innodb_page_cleaners = 4
innodb_undo_log_truncate = 1
innodb_max_undo_log_size = 2G
innodb_purge_rseg_truncate_frequency = 128
binlog_gtid_simple_recovery=1
log_timestamps=system
transaction_write_set_extraction=MURMUR32
show_compatibility_56=on

 

第二份如下:看了一下第一份设置的内存很大,所以一般的机器不要用,否则启动的时候就死机了。

根据自己机器的内存大小来调整相关buffer的大小,以下是我的配置文件,大部分注释,根据需要进行修改,myisam部分可以不用了,因为现在基本使用innodb引擎。

[root@localhost data]# cat /etc/my.cnf
[client]
port = 3306
socket =/application/mysql/tmp/mysql.sock
default-character-set = utf8

[mysql]
no-auto-rehash 

[mysqld]
user = mysql
port = 3306
character-set-server = utf8
socket = /application/mysql/tmp/mysql.sock
basedir = /application/mysql
datadir = /application/mysql/data
log-error = /application/mysql/data/mysql_err.log
pid-file = /application/mysql/data/mysql.pid








#bulk_insert_buffer_size = 64M
#myisam_sort_buffer_size = 64M
#myisam_max_sort_file_size = 10G
#myisam_repair_threads = 1
#myisam_recover

long_query_time = 2
slow_query_log
slow_query_log_file = /application/mysql/data/slow.log
skip-name-resolv
#skip-locking
#skip-networking

server-id = 1


#bin log configure options by clc
#log_slave_updates = 1
#log-bin = /application/mysql/data/mysql-bin
#binlog_format = mixed
#binlog_cache_size = 4M
#max_binlog_cache_size = 8M
#max_binlog_size = 1G
#expire_logs_days = 90
#binlog-ignore - db = mysql
#binlog-ignore - db = information_schema
 

#sort_buffer_size = 2M #system default
#join_buffer_size = 2M #system default
#thread_cache_size = 38 #system default
#key_buffer_size = 64M #ram is 4GB ,can set 256M
#read_buffer_size = 128k #system default
#bulk_insert_buffer_size = 8M #system default

#read_rnd_buffer_size = 16M
#query_cache_size = 32M
#query_cache_limit = 2M
#query_cache_min_res_unit = 2k
#thread_concurrency = 32
 
#table_cache = 614
#table_open_cache = 512
#open_files_limit = 10240
#back_log = 600
#max_connections = 5000
#max_connect_errors = 6000
#external-locking = FALSE
 
#max_allowed_packet = 16M
#thread_stack = 192K
#transaction_isolation = READ-COMMITTED
#tmp_table_size = 256M
#max_heap_table_size = 512M
 
 
 
#innodb engine configure

#innodb_additional_mem_pool_size = 16M
#innodb_buffer_pool_size = 512M
#innodb_data_file_path = ibdata1:256M:autoextend
#innodb_file_io_threads = 4
#innodb_thread_concurrency = 8
#innodb_flush_log_at_trx_commit = 2
#innodb_log_buffer_size = 16M
#innodb_log_file_size = 128M
#innodb_log_files_in_group = 3
#innodb_max_dirty_pages_pct = 90
#innodb_lock_wait_timeout = 120
#innodb_file_per_table = 0
 
[mysqldump]
quick
max_allowed_packet = 64M
 
[mysqld_safe]
log-error = /application/mysql/data/mysql_err.log
pid-file = /application/mysql/data/mysql.pid
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

原文链接:mysql5.6/5.7配置文件,转载请注明来源!

0