linux doris 环境下增加只读账号
一:登录系统
root@baidu-bj-bigdata-1:~# mysql -h 10.10.0.14 -P 9030 -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3890
Server version: 5.7.99 Doris version doris-2.0.11-22edcabbb0
Copyright (c) 2000, 2024, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| __internal_schema |
| information_schema |
| mysql |
| umi |
+--------------------+
4 rows in set (0.00 sec)
二:查看账号
mysql> SHOW GRANTS FOR 'read'@'%';
ERROR 1105 (HY000): errCode = 2, detailMessage = User: 'default_cluster:read'@'%' does not exist
三:添加只读权限
mysql> CREATE USER 'read'@'%' IDENTIFIED BY 'read@2024';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT SELECT_PRIV ON umi.* TO 'read'@'%';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT SELECT_PRIV ON umi.dim_recommend_feature_keys TO 'read'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALTER_PRIV ON umi.dim_recommend_feature_keys TO 'read'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT CREATE_PRIV ON umi.dim_recommend_feature_keys TO 'read'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT DROP_PRIV ON umi.dim_recommend_feature_keys TO 'read'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT LOAD_PRIV ON umi.dim_recommend_feature_keys TO 'read'@'%';
Query OK, 0 rows affected (0.00 sec)
四:查看权限
mysql> SHOW GRANTS FOR 'read'@'%';
+----------------------------+----------+-------+-------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------+----------+---------------+---------------------+
| UserIdentity | Password | Roles | GlobalPrivs | CatalogPrivs | DatabasePrivs | TablePrivs | ColPrivs | ResourcePrivs | WorkloadGroupPrivs |
+----------------------------+----------+-------+-------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------+----------+---------------+---------------------+
| 'default_cluster:read'@'%' | Yes | | NULL | NULL | internal.default_cluster:information_schema: Select_priv ; internal.default_cluster:mysql: Select_priv ; internal.default_cluster:umi: Select_priv | internal.default_cluster:umi.dim_recommend_feature_keys: Select_priv Load_priv Alter_priv Create_priv Drop_priv | NULL | NULL | normal: Usage_priv |
+----------------------------+----------+-------+-------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------+----------+---------------+---------------------+
1 row in set (0.00 sec)
mysql> exit
Bye