Tdengine采用docker启动时注入密码TAOS_ROOT_PASSWORD不生效

【TDengine 使用环境】
生产环境 /测试/ Poc/预生产环境

【TDengine 版本】

3.4.1.16

【操作系统以及版本】

ubuntu 20.04

【部署方式】容器/非容器部署

容器

【遇到的问题:问题现象及影响】

我采用docker-compose.yaml启动,将TAOS_ROOT_PASSWORD环境变量注入,发现不生效,容器日志10:06:03.151924 00000363 REP WARN create database sql: create database if not exists log cachemodel ‘both’ keep 90 vgroups 1 buffer 64
07/15 10:06:03.154927 00000133 E MND ERROR user:root, failed to login from 127.0.0.1 since Authentication failure, line:390, db:, QID:0x3d41408623920001:0x4bd0363862300003
07/15 10:06:03.154947 00000133 E MND ERROR msg:0x7fa61400b948, failed to process since Authentication failure, app:(nil) type:connect, QID:0x3d41408623920001:0x4bd0363862300003
07/15 10:06:03.155669 00000320 CNP ERROR connect to taos failed: [0x357] Authentication failure, conn_type:password, user:root
07/15 10:06:03.155793 00000320 RST ERROR QID:0x227b363862300001 connect server error, ip:127.0.0.1, err:[0x357] Authentication failure
07/15 10:06:03.156169 00000363 DB ERROR QID:0x4000000000000003 Authentication failure
07/15 10:06:15.005900 00000320 MON ERROR upload_id:0x2000000000000100, upload to keeper error, err:Post “http://127.0.0.1:6043/adapter_report”: dial tcp 127.0.0.1:6043: connect: connection refused
07/15 10:06:30.005689 00000320 MON ERROR upload_id:0x2000000000000200, upload to keeper error, err:Post “http://127.0.0.1:6043/adapter_report”: dial tcp 127.0.0.1:6043: connect: connection refused
2026-07-15 10:06:36 [INFO] Starting taosx…
2026-07-15 10:06:37 [INFO] → Creating xnode for taosx with root taosdata.
07/15 10:06:37.103578 00000133 E MND ERROR user:root, failed to login from 127.0.0.1 since Authentication failure, line:390, db:, QID:0x64924e86a82e0001:0x4e8e36386a800002
07/15 10:06:37.103596 00000133 E MND ERROR msg:0x7fa5e4015bf8, failed to process since Authentication failure, app:(nil) type:connect, QID:0x64924e86a82e0001:0x4e8e36386a800002
2026-07-15 10:06:37 [INFO] Xnode creation output:
Welcome to the TDengine TSDB Command Line Interface, Native Client Version:3.4.1.16.enterprise
Copyright (c) 2025 by TDengine TSDB, all rights reserved.

failed to connect to server, reason: Authentication failure [0x80000357]

To view possible causes and suggested actions for error codes, see
“Error Code Reference” in the TDengine online documentation.
2026-07-15 10:06:37 [INFO] :warning: Xnode creation failed (exit code: 255)

docker 容器第一次启动时,TAOS_ROOT_PASSWORD 会设置 root 密码。但如果容器重启过挂载了持久化数据卷,密码已经写入了 /var/lib/taos 的数据文件中,后续再改 TAOS_ROOT_PASSWORD 环境变量不会覆盖已存在的密码

日志中版本是 3.4.1.16,文档说明:

对于 3.3.8.8 及以上版本,可以通过 TAOS_ROOT_PASSWORDTAOS_ROOT_PASSWORD_FILE 提供当前 root 密码。如果此前已经修改过 root 密码,在升级、重启容器或重建 Pod 之前,仍需确保部署配置中提供的是当前实际密码。

也就是说:TAOS_ROOT_PASSWORD 不是用来改密码的,是提供给容器用来登录的。 如果容器内的密码已经变了,环境变量也要跟着变。