02-influxdb的權限管理

介紹

其實influxdb的權限語法和mysql基本相似,看完以後你基本就能瞭解;

授權語法

  1. 創建用戶:CREATE USER <username> WITH PASSWORD '<password>'
  2. 授權權限:GRANT [READ,WRITE,ALL] ON <database_name> TO <username>
  3. 創建並授權:CREATE USER <username> WITH PASSWORD '<password>' WITH ALL PRIVILEGES
  4. 取消授權:REVOKE ALL PRIVILEGES FROM <username>
  5. 修改密碼:SET PASSWORD FOR <username> = '<password>'
  6. 刪除用戶:DROP USER <username>

開啓登錄認證
vim /etc/influxdb/influxdb.conf

[http]
auth-enabled = true

[root@localhost tmp]# influx

Connected to http://localhost:8086 version 1.7.1
InfluxDB shell version: 1.7.1
Enter an InfluxQL query
> show databases
ERR: unable to parse authentication credentials
Warning: It is possible this error is due to not setting a database.
Please set a database with the command "use <database>".
> auth
username: monitor
password:
> show databases
name: databases
name
----
_internal
zabbix
telegraf
chronograf
> quit

授權操作

1.創建超級用戶
創建用戶:monitor
密碼:zabbix
權限:全部權限(超級用戶)
create user monitor with password 'zabbix' with all privileges

2.創建只讀用戶
用戶:monitor_ro
數據庫:monitordb
權限:指定數據庫的只讀權限

create user monitor_ro with password 'zabbix_apipwd'
grant read on monitordb to monitor_ro

3.創建可以寫用戶
用戶:monitor_rw
數據庫:monitordb
權限:指定數據庫的寫權限

create user monitor_rw with password 'zabbix_apipwd'
grant write on monitordb to monitor_rw

4.取消用戶授權
取消用戶授權:

REVOKE ALL PRIVILEGES FROM monitor_rw

5.查看所有用戶

SHOW USERS
user admin


monitor true
monitor_ro false
monitor_rw false

6.刪除用戶

DROP USER monitor_rw

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章