暂无图片
Step by Step之三:OB4.0社区版数据库的基本操作
最近更新:2023-07-17 16:24:27

在test_tenant租户上创建用户、赋予权限和创建数据库,然后使用该用户登录数据库,创建表、修改表等操作。通过具体实验,了解、熟悉OB4.0数据的使用。

1、创建用户、赋予权限

[root@node1 ~]# obclient -h127.0.0.1 -P2881 -uroot@test_tenant  -A
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221513609
Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:28:27)

Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

obclient [(none)]> CREATE USER 'test_user' IDENTIFIED BY 'test_user';
Query OK, 0 rows affected (4.219 sec)

obclient [(none)]> grant all on *.* to test_user;
Query OK, 0 rows affected (2.188 sec)
obclient [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| oceanbase          |
| test               |
+--------------------+
4 rows in set (0.019 sec)

2、使用test_user,创建数据库test_db

  [root@node1 ~]# obclient -h127.0.0.1 -P2881 -utest_user@test_tenant  -ptest_user
Welcome to the OceanBase.  Commands end with ; or \g.
Your OceanBase connection id is 3221513610
Server version: OceanBase_CE 4.0.0.0 (r103000022023011215-05bbad0279302d7274e1b5ab79323a2c915c1981) (Built Jan 12 2023 15:28:27)

Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient [(none)]>  create database test_db default character set utf8mb4;
Query OK, 1 row affected (3.890 sec)
obclient [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
......