docker run \
-d --restart=always \
-p 7986:8086 \
-v /data/influx/alpha:/var/lib/influxdb \
--name=alpha influxdb:alpine
docker exec -it alpha influx
CREATE USER "admin" WITH PASSWORD 'password' WITH ALL PRIVILEGES
docker stop alpha && docker rm alpha
docker run \
-d --restart=always \
-p 7986:8086 \
-e INFLUXDB_HTTP_AUTH_ENABLED=true \
-v /data/influx/alpha:/var/lib/influxdb \
--name=alpha influxdb:alpine
docker exec -it alpha influx
AUTH admin password
# 创建数据库
CREATE DATABASE telegraf
# 根据需要设置数据库的保存时间(尽量按需要调整,避免保存了过期的统计数据)
CREATE RETENTION POLICY "one_week" ON "telegraf" DURATION 1w REPLICATION 1 DEFAULT
# 只可读
CREATE USER "reader" WITH PASSWORD '123456'
GRANT READ ON "telegraf" TO "reader"
# 只可写
CREATE USER "writer" WITH PASSWORD '123456'
GRANT WRITE ON "telegraf" TO "writer"
# 所有权限
CREATE USER "user" WITH PASSWORD '123456'
GRANT ALL ON "telegraf" TO "user"