以下幾個參數,在 MySQL 8.0 不在繼續支援、使用:
- query-cache-type
- query-cache-size
- innodb_large_prefix
整理過後,我的 MySQL 8 設定檔如下:
[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
log-error       = /var/log/mysql/error.log
default-authentication-plugin = mysql_native_password
performance_schema = Off
default-storage-engine         = InnoDB
character-set-server           = utf8mb4
collation-server               = utf8mb4_unicode_ci
init_connect='SET collation_connection = utf8mb4_unicode_ci'
init_connect='SET NAMES utf8mb4'
# LOGGING #
log-error    = /var/log/mysql/error.log
log-error                      = /var/lib/mysql/mysql-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /var/lib/mysql/mysql-slow.log
binlog_expire_logs_seconds     = 86400  # 1 day
max-binlog-cache-size          = 4M
max-binlog-size                = 128M
# MyISAM #
key-buffer-size                = 16M
myisam-recover-options         = FORCE,BACKUP
max-allowed-packet             = 16M
max-connect-errors             = 1000000
# BINARY LOGGING #
server-id                      = 4782375
log-bin                        = /var/lib/mysql/mysql-bin
expire-logs-days               = 14
sync-binlog                    = 1
# MyISAM #
key-buffer-size                = 16M
myisam-recover-options         = FORCE,BACKUP
max-allowed-packet             = 16M
max-connect-errors             = 1000000
# CACHES AND LIMITS #
tmp-table-size                 = 16M
max-heap-table-size            = 32M
max-connections                = 100
thread-cache-size              = 50
open-files-limit               = 65535
table-definition-cache         = 1024
table-open-cache               = 524288
# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 16M
innodb-flush-log-at-trx-commit = 1
innodb-log-file-size           = 64M
# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_ALL_TABLES
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqldump]
default-character-set = utf8mb4gist 連結:https://gist.github.com/johnroyer/43f18557ad9ff3070b1d22e7b957f950
