Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pingcap/tidb/llms.txt

Use this file to discover all available pages before exploring further.

TiDB reads its configuration from a TOML file. By default, tidb-server looks for no config file and uses built-in defaults. Pass a config file explicitly with the --config flag:
tidb-server --config=/path/to/config.toml
Only a subset of options can be changed at runtime via the HTTP status API. Most options require a server restart to take effect.

Server

Top-level keys that control how tidb-server exposes itself to clients.
host
string
default:"\"0.0.0.0\""
IP address the MySQL protocol listener binds to.
port
integer
default:"4000"
TCP port for MySQL client connections.
socket
string
default:"\"/tmp/tidb-{Port}.sock\""
Unix domain socket path for local client connections. The {Port} placeholder is replaced with the actual port value.
advertise-address
string
default:"\"\""
IP address advertised to other TiDB components and clients. Useful when the host has multiple interfaces. Defaults to host when empty.
token-limit
integer
default:"1000"
Maximum number of concurrent sessions. Requests beyond this limit are queued.

Storage

store
string
default:"\"unistore\""
Storage backend. Accepted values:
ValueDescription
tikvDistributed storage via a running TiKV cluster (production)
unistoreBuilt-in single-node store, no external dependencies (development)
mocktikvIn-memory mock, for testing only
path
string
default:"\"/tmp/tidb\""
Data directory used by the unistore and mocktikv backends. When store = "tikv" this is the PD cluster address (e.g. "127.0.0.1:2379").

Log

Configured under the [log] section.
log.level
string
default:"\"info\""
Minimum log level. Accepted values (in increasing severity): debug, info, warn, error, fatal.
log.format
string
default:"\"text\""
Log output format. Use "json" for structured logging pipelines; "text" for human-readable output.
log.slow-query-file
string
default:"\"tidb-slow.log\""
File to write slow query records. Set to "" to merge slow query logs into the main log.

Log file rotation ([log.file])

log.file.filename
string
default:"\"\""
Path to the log file. When empty, logs are written to stderr.
log.file.max-size
integer
default:"300"
Maximum size of a single log file in megabytes (upper limit: 4096 MB). A new file is created when this size is reached.
log.file.max-days
integer
default:"0"
Number of days to retain old log files. 0 disables time-based cleanup.
log.file.max-backups
integer
default:"0"
Maximum number of rotated log files to keep. 0 disables count-based cleanup.

Performance

Configured under the [performance] section.
performance.stats-lease
string
default:"\"3s\""
Interval at which TiDB refreshes table statistics from storage. Shorter values produce fresher stats at the cost of more background I/O.
performance.stmt-count-limit
integer
default:"5000"
Maximum number of statements allowed inside a single transaction.
performance.max-procs
integer
default:"0"
Number of OS threads (GOMAXPROCS). 0 uses all available CPU cores.

Security

Configured under the [security] section.
security.ssl-ca
string
default:"\"\""
Path to the PEM file containing trusted CA certificates for MySQL client connections. TLS is disabled when this and the cert/key paths are all empty.
security.ssl-cert
string
default:"\"\""
Path to the X.509 certificate in PEM format presented to MySQL clients.
security.ssl-key
string
default:"\"\""
Path to the private key in PEM format corresponding to ssl-cert.
Set auto-tls = true under [security] to let TiDB generate a self-signed certificate automatically on first start. This is the recommended approach for development environments.

Memory

performance.server-memory-quota
integer
default:"0"
Total memory limit for the tidb-server process in bytes. 0 means unlimited — TiDB will use as much memory as the OS allows.
tmp-storage-quota
integer
default:"-1"
Maximum disk space in bytes for temporary files spilled to disk when a query exceeds its memory limit. -1 means TiDB does not check available capacity.

Minimal configuration example

# TiDB server
host = "0.0.0.0"
port = 4000
advertise-address = "192.168.1.10"
store = "tikv"
path = "192.168.1.20:2379"    # PD address when using TiKV
token-limit = 1000

[log]
level = "info"
format = "json"
slow-query-file = "/var/log/tidb/tidb-slow.log"

[log.file]
filename = "/var/log/tidb/tidb.log"
max-size = 300
max-days = 7
max-backups = 5

[security]
ssl-ca   = "/etc/tidb/ca.pem"
ssl-cert = "/etc/tidb/tidb-server.pem"
ssl-key  = "/etc/tidb/tidb-server-key.pem"

[performance]
stats-lease = "3s"
server-memory-quota = 17179869184    # 16 GiB

Dynamic configuration via HTTP API

You can view the current running configuration and update select settings at runtime via the HTTP status API (default port 10080):
# View current full configuration as JSON
curl http://127.0.0.1:10080/config
To change runtime settings without a restart, use POST /settings (a separate endpoint):
# Change log level at runtime
curl -X POST -d "log_level=debug" http://127.0.0.1:10080/settings

# Re-enable general query log
curl -X POST -d "tidb_general_log=1" http://127.0.0.1:10080/settings
Runtime changes made via /settings are not persisted to disk. Update config.toml and restart tidb-server to make changes permanent. See the Administration API for the full list of settable parameters.

Build docs developers (and LLMs) love