通过 TiUP 工具编辑 TiDB 的配置文件,将 sql_mode 参数添加到 [tidb] 部分,然后应用配置修改。
具体步骤如下:
编辑集群配置:
tiup cluster edit-config <cluster-name>
在编辑器中添加或修改 [tidb] 部分下的 sql_mode 参数:
tidb_servers:
- host: 10.0.1.1
config:
instance.sql-mode: "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
保存并退出编辑器。
应用配置修改:
tiup cluster reload <cluster-name>
这种方法可以确保在集群重启后,sql_mode 参数仍然有效。
配置完成后,会写入tidb的配置文件中:
[root@uat-server-2 conf]# pwd
/data/tidb/tidb-deploy/tidb-4000/conf
[root@uat-server-2 conf]# cat tidb.toml
# WARNING: This file is auto-generated. Do not edit! All your modification will be overwritten!
# You can use 'tiup cluster edit-config' and 'tiup cluster reload' to update the configuration
# All configuration items you want to change can be added to:
# server_configs:
# tidb:
# aa.b1.c3: value
# aa.b2.c4: value
[instance]
sql-mode = "STRICT_TRANS_TABLES"


