1、首先准备预设的配置条目

[mysqld]
port=6606
lower_case_table_names=1
event_scheduler=ON
max_connections=2000
wait_timeout=1800
max_user_connections=800
innodb_buffer_pool_size=2048M
innodb_log_buffer_size=20M
query_cache_size=40M



datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
user=root
symbolic-links=0
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'

2、查看目前MySQL已经配置生效的条目

bash-4.2# mysqld --help --verbose                                     //运行该命令
mysqld Ver 5.7.39 for Linux on x86_64 (MySQL Community Server (GPL))
Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Starts the MySQL database server.

Usage: mysqld [OPTIONS]

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf //MySQL启动时从以上目录读取配置文件
The following groups are read: mysqld server mysqld-5.7
-------------------------省略-------------------------
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
------------------------------------------------------------ -------------
abort-slave-event-count 0
allow-suspicious-udfs FALSE
archive ON
auto-generate-certs TRUE
auto-increment-increment 1
auto-increment-offset 1
autocommit TRUE
automatic-sp-privileges TRUE
avoid-temporal-upgrade FALSE
back-log 450
basedir /usr/
big-tables FALSE
bind-address *
binlog-cache-size 32768
binlog-checksum CRC32
binlog-direct-non-transactional-updates FALSE
binlog-error-action ABORT_SERVER
binlog-format ROW
binlog-group-commit-sync-delay 0
binlog-group-commit-sync-no-delay-count 0
binlog-gtid-simple-recovery TRUE
binlog-max-flush-queue-time 0

3、对比查看,发现是一致的

bash-4.2# mysqld --help --verbose |grep sql-mode
--sql-mode=name Syntax: sql-mode=mode[,mode[,mode...]]. See the manual
sql-mode STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION