# 登录root用户下的starrock[root@master ~]# mysql -h 192.168.1.1 -P 9030 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 610
Server version: 5.1.0 StarRocks version 2.1.3
Copyright (c)2000, 2022, 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> CREATE USER'test' IDENTIFIED BY 'test';
Query OK, 0 rows affected (0.00 sec)# 创建数据库
mysql> create database doris;
Query OK, 0 rows affected (0.00 sec)
mysql> create database test;
Query OK, 0 rows affected (0.00 sec)# 赋权
mysql> grant all on test to test;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on doris to test;
Query OK, 0 rows affected (0.00 sec)# 退出root用户
mysql>[5]+ 已停止 mysql -h 192.168.1.1 -P 9030 -uroot -p123456
# 登录test用户[root@master ~]# mysql -h 192.168.1.1 -P 9030 -utest -ptest
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 615
Server version: 5.1.0 StarRocks version 2.1.3
Copyright (c)2000, 2022, 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 |
+--------------------+
| doris || information_schema ||test|
+--------------------+
3 rows inset(0.00 sec)
mysql> use test;
Database changed
mysql> show tables;
Empty set(0.00 sec)
mysql>
取消赋权
# 登录root用户下的starrock[root@master ~]# mysql -h 192.168.1.1 -P 9030 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 610
Server version: 5.1.0 StarRocks version 2.1.3
Copyright (c)2000, 2022, 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> revoke all on test from test;
Query OK, 0 rows affected (0.00 sec)