influxdata-docker icon indicating copy to clipboard operation
influxdata-docker copied to clipboard

ERR: authorization failed for non-admin user

Open anirvanr opened this issue 5 years ago • 4 comments

I'm getting "ERR: authorization failed" when executing USE command from CLI

admin user

influx -host influx.example.com -username admin -password admin
Connected to http://influx.example.com:8086 version 1.5.4
InfluxDB shell version: v1.7.2
Enter an InfluxQL query
> show databases;
name: databases
name
----
telegraf
_internal
> SHOW USERS
user             admin
----             -----
admin            true
telegraf         false
> SHOW GRANTS FOR telegraf
database privilege
-------- ---------
telegraf ALL PRIVILEGES
> GRANT ALL ON "telegraf" TO "telegraf"
> SHOW GRANTS FOR telegraf
database privilege
-------- ---------
telegraf ALL PRIVILEGES
> exit

non-admin user

influx -host influx.example.com -username telegraf -password telegraf
Connected to http://influx.example.com:8086 version 1.5.4
InfluxDB shell version: v1.7.2
Enter an InfluxQL query
> use telegraf
WARN: authorization failed
Using database telegraf
> SHOW MEASUREMENTS
ERR: authorization failed

anirvanr avatar May 16 '19 06:05 anirvanr

Do you solved your problem ?

frateralexander avatar Apr 06 '20 11:04 frateralexander

You need to use ', like influx -host influx.example.com -username 'admin' -password 'admin'

Zefau avatar Oct 25 '20 08:10 Zefau

I have this exact issue and I have not been able to resolve it by placing single quotes around the username or password. Has anyone else been able to make progress in resolving this?

Using the same credentials, I am able to write to the database using the HTTP API, but when I connect using the cli via a docker container with the credentials I experience the same behaviour as the original poster.

Any further ideas - this one is driving me mad. Thanks.

williamhargrove avatar Aug 13 '21 09:08 williamhargrove

Stumbled across this thread. I found the solution I think. Posting here in case it helps others with the "Authorization failed" message.

It appears as if passing credentials with -username and -password might only work for admin users. For normal users, instead use the auth command at the influx pronpt:

# influx
Connected to http://xxx...
InfluxDB shell version: 1.8.9
> auth
username: <user>
password: <password>
> show databases

BigBadaboom avatar Feb 22 '24 04:02 BigBadaboom