具体配置看个人需求
Mysql5.7
[mysql]
port = 3306
default-character-set=utf8mb4
#socket=/data/mysql/mysql.sock
[mysqld]
##########################
# summary
##########################
#user = mysql
bind-address = 0.0.0.0
port = 3306
#basedir=/data/mysql
#datadir=/data/mysql/data
#socket=/data/mysql/mysql.sock
#tmpdir = /tmp
#pid-file=/tmp/mysqld.pid
#skip-grant-tables
#skip-networking
# 默认安装后error_log,slow_log 日志时间戳默认为UTC
log_timestamps=SYSTEM
explicit_defaults_for_timestamp=1
lower_case_table_names=1
table_open_cache = 8000
##########################
# time out
##########################
connect_timeout = 20
wait_timeout = 600
##########################
# connection
##########################
max_connections = 2000
max_user_connections = 1900
max_connect_errors = 100000
max_allowed_packet = 1G
##########################
# character set
##########################
character-set-server = utf8mb4
collation-server = utf8mb4_bin
##########################
# log bin
##########################
#server-id = 1
#log_bin = mysql-bin
# ROW、STATEMENT、MIXED
#binlog_format = row
#sync_binlog = 1
#expire_logs_days = 7
#binlog_cache_size = 128m
#max_binlog_cache_size = 512m
#max_binlog_size = 256M
#master_info_repository=TABLE
#relay_log_info_repository=TABLE
#log_slave_updates=ON
#binlog_checksum=none
#binlog_ignore_db=information_schema
#binlog_ignore_db=mysql
#binlog_ignore_db=performation_schema
#binlog_ignore_db=sys
#binlog_do_do=
#replicate_ignore_db=information_schema
#replicate_ignore_db=mysql
#replicate_ignore_db=performance_schema
#replicate_ignore_db=sys
#replicate_do_db=
##########################
# gtid
##########################
#gtid_mode = on
#enforce_gtid_consistency = on
##########################
# slave parallel
##########################
#slave_net_timeout=60
#slave_parallel_type=LOGICAL_CLOCK
#slave_parallel_workers=4
##########################
# log relay
##########################
#relay_log = mysql-relay-bin
#relay_log_purge = on
#relay_log_recovery = on
#max_relay_log_size = 1G
##########################
# log error
##########################
log_error=/data/mysql/logs/mysqld_error.log
##########################
# log slow
##########################
slow_query_log = on
slow_query_log_file = /data/mysql/logs/mysqld_slow.log
long_query_time = 2
log_queries_not_using_indexes = on
##########################
# log general
##########################
general_log = on
general_log_file = /data/mysql/logs/mysqld_gener.log
##########################
# thread pool
##########################
#thread_handling=pool-of-threads
#thread_handling=one-thread-per-connection
#thread_pool_oversubscribe=8
##########################
# innodb
##########################
#innodb_file_per_table=1
#innodb_log_file_size=1024M
#innodb_log_buffer_size=64M
##########################
# password policy
# after init
##########################
#validate_password_policy=0
#validate_password_length=4
#validate_password_mixed_case_count=0
#validate_password_number_count=0
#validate_password_special_char_count=0
Mysql 8
[mysql]
port = 3306
default-character-set=utf8mb4
socket=/data/mysql/mysql.sock
[mysqld]
#----------------优化配置(说明从上到下)
## 支持符号链接,就是可以通过软连接的方式,管理其他目录的数据库,最好不要开启,当一个磁盘或分区空间不够时,可以开启该参数将数据存储到其他的磁盘或分区
#symbolic-links=0
## 设置autocommit=0,则用户将一直处于某个事务中,直到执行一条commit提交或rollback语句才会结束当前事务重新开始一个新的事务(调试模式时使用)
##autocommit=0
## MySQL读入缓冲区的大小
#read_buffer_size = 100M
## MySQL的随机读缓冲区大小、MySQL的顺序读缓冲区大小
#read_rnd_buffer_size = 100M
#sort_buffer_size = 100M
## 连接缓存池大小、临时表大小、临时存放位置
#join_buffer_size = 128M
#tmp_table_size = 100M
##########################
# summary
##########################
#user = mysql
bind-address = 0.0.0.0
port = 3306
#basedir=/data/mysql
#datadir=/data/mysql/data
#socket=/data/mysql/mysql.sock
#tmpdir = /tmp
#pid-file=/tmp/mysqld.pid
#skip-grant-tables
#skip-networking
# 默认安装后error_log,slow_log 日志时间戳默认为UTC
log_timestamps=SYSTEM
explicit_defaults_for_timestamp=1
table_open_cache = 8000
##########################
# 连接超时时间、保持时间、最大传输数据包大小
##########################
connect_timeout = 20
wait_timeout = 600
interactive_timeout=2880000
##########################
# connection
##########################
max_connections = 2000
max_user_connections = 1900
max_connect_errors = 100000
max_allowed_packet = 1G
##########################
# character set
##########################
character-set-server = utf8mb4
collation-server = utf8mb4_bin
##########################
# log bin
##########################
#server-id = 1
#log_bin = mysql-bin
# ROW、STATEMENT、MIXED
#binlog_format = row
#sync_binlog = 1
#expire_logs_days = 7
#binlog_cache_size = 128m
#max_binlog_cache_size = 512m
#max_binlog_size = 256M
#master_info_repository=TABLE
#relay_log_info_repository=TABLE
#log_slave_updates=ON
#binlog_checksum=none
#binlog_ignore_db=information_schema
#binlog_ignore_db=mysql
#binlog_ignore_db=performation_schema
#binlog_ignore_db=sys
#binlog_do_do=
#replicate_ignore_db=information_schema
#replicate_ignore_db=mysql
#replicate_ignore_db=performance_schema
#replicate_ignore_db=sys
#replicate_do_db=
##########################
# gtid
##########################
#gtid_mode = on
#enforce_gtid_consistency = on
##########################
# slave parallel
##########################
#slave_net_timeout=60
#slave_parallel_type=LOGICAL_CLOCK
#slave_parallel_workers=4
##########################
# log relay
##########################
#relay_log = mysql-relay-bin
#relay_log_purge = on
#relay_log_recovery = on
#max_relay_log_size = 1G
##########################
# log error
##########################
log_error=/data/mysql/logs/mysqld_error.log
##########################
# log slow
##########################
##超出次设定值的SQL即被记录到慢查询日志
slow_query_log = on
slow_query_log_file = /data/mysql/logs/mysqld_slow.log
long_query_time = 2
##表示记录下没有使用索引的查询
log_queries_not_using_indexes = on
##记录管理语句
log_slow_admin_statements = 1
##开启复制从库复制的慢查询的日志
log_slow_slave_statements = 1
##设置每分钟增长的没有使用索引查询的日志数量
log_throttle_queries_not_using_indexes = 10
# 3天
#expire_logs_days = 3
#binlog_expire_logs_seconds=259200
#min_examined_row_limit = 100
##########################
# log general
##########################
general_log = on
general_log_file = /data/mysql/logs/mysqld_gener.log
#innodb_lock_wait_timeout=600
#lower_case_table_names=1