Cockroachdb 四、用户管理及授权
四 用户管理及授权
用户管理
简介
# Create a user:
cockroach user set <username> <flags>
# List all users:
cockroach user ls <flags>
# Display a specific user:
cockroach user get <username> <flags>
# Delete a specific user:
cockroach user rm <username>
示例
创建用户,及修改用户密码
cockroach user set username --certs-dir=certs --host=127.0.0.1 --password
列出所有用户
cockroach user ls --certs-dir=certs --host=10.2.0.14
+------------+
| username |
+------------+
| jpointsman |
| maxroach |
| username |
+------------+
(3 rows)
显示用户信息
cockroach user get username --certs-dir=certs --host=10.2.0.14
+----------+--------------------------------------------------------------+
| username | hashedPassword |
+----------+--------------------------------------------------------------+
| username | $2a$10$H5.c5eQYUJJ1LW/r74NvPuDxkZXwrfeIpTk8CIbheKKRhLW0zxL1. |
+----------+--------------------------------------------------------------+
(1 row)
删除用户
cockroach user rm username --certs-dir=certs --host=10.2.0.14
登录
cockroach sql --certs-dir=certs --user=username --password
授权
简介基本语法
GRANT role ON DATABASE database | TABLE db.table TO user
REVORKE role ON DATABASE database| TABLE db.table FROM user
SHOW GRANTS ON DATABSE database| TABLE db.table FOR user
图例