DEV Community

PeterMilovcik
PeterMilovcik

Posted on • Edited on

How to Create a Bucket With InfluxDB v2.1 CLI

There are a couple of changes in InfluxDB CLI if you upgrade from 1.X to 2.1. The database is now called a "bucket," and it's pretty different when creating one using CLI. Here is what I've learned the hard way (by trial & error and googling):

There is no
influx -execute 'SHOW DATABASES'
or influx -execute 'CREATE DATABASE Foo'.

There are buckets instead, and you need permission to create one:
influx auth create -o MyOrg --write-buckets

In v2.1, I have not found any --all-access flag.

If you have permission, create a bucket:
influx bucket create -n BucketName -o MyOrg -r 7d

When you try to import data to your new bucket and import fails with an error message Not Found {"code":"not found","message":"no dbrp mapping found"} you need to create a mapping from bucket to retention policy.

DBRP stands for "Database and Retention Policy"

(Shouldn't that be also changed to Bucket and Retention Policy (BRP)?)

Here is how you can create a mapping between a bucket and DBRP for a "week":

First, if you don't have one already, you need permission:
influx auth create -o MyOrg --write-dbrps

Second, create a mapping:
influx v1 dbrp create --db BucketName --rp week --bucket-id mybucketid --default

And that's it. Import should be successful now.

I'm still a newbie with the InfluxDB. If you have a better way to do this or I miss something, let me know in the comments. I'd love to learn more!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more