This topic explains how to work with an already deployed OceanBase AI Database cluster to create and log in to a user tenant, create a business database, and run basic queries, helping you complete your first use of OceanBase AI Database quickly.
Prerequisites
- An OceanBase AI Database cluster has been deployed. For the deployment process, see Deployment process.
- You have obtained the root user password of the cluster's sys tenant, which is the root@sys password set during cluster creation.
- The OBClient client has been installed. For more connection methods, see Overview of connection methods.
Step 1: Create a user tenant
OceanBase AI Database is a natively distributed database. Multiple database instances can run in the same database at the same time. The first step is usually to create a tenant (database instance), and then use it like a traditional standalone database instance.
OceanBase AI Database supports creating only user tenants. The system tenant is created automatically when the cluster is created. The procedure for creating a user tenant is as follows:
Create a resource unit.
Log in to the
systenant of the cluster as therootuser.obclient -h172.30.xx.xx -P2883 -uroot@sys#cluster -p**** -AEnter the
oceanbasedatabase.obclient(root@sys)[(none)]> USE oceanbase;Query the
DBA_OB_UNIT_CONFIGSview for existing resource unit information.obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS;The query result is as follows:
+----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+---------------------+---------------------+-------------+---------------------+----------------------+ | UNIT_CONFIG_ID | NAME | CREATE_TIME | MODIFY_TIME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | DATA_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | MAX_NET_BANDWIDTH | NET_BANDWIDTH_WEIGHT | +----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+---------------------+---------------------+-------------+---------------------+----------------------+ | 1 | sys_unit_config | 2026-09-01 16:31:19.277829 | 2026-09-01 16:31:19.277829 | 1 | 1 | 5368709120 | 7516192768 | 10737418240 | 9223372036854775807 | 9223372036854775807 | 1 | 9223372036854775807 | 1 | +----------------+-----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+---------------------+---------------------+-------------+---------------------+----------------------+ 1 row in set (0.002 sec)For detailed information about the
DBA_OB_UNIT_CONFIGSview, see DBA_OB_UNIT_CONFIGS.Create a resource unit using the
CREATE RESOURCE UNITstatement.Example: Create a resource unit named
S1_unit_configwith 1 CPU core and 5 GB of memory.obclient(root@sys)[oceanbase]> CREATE RESOURCE UNIT S1_unit_config MEMORY_SIZE = '5G', MAX_CPU = 1, MIN_CPU = 1;For detailed information about this statement, see the Create a resource unit section in Create a tenant.
Query the
DBA_OB_UNIT_CONFIGSview to confirm that the resource unitS1_unit_confighas been created successfully.obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_UNIT_CONFIGS WHERE NAME = 'S1_unit_config';The query result is as follows:
+----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+---------------------+---------------------+-------------+---------------------+----------------------+ | UNIT_CONFIG_ID | NAME | CREATE_TIME | MODIFY_TIME | MAX_CPU | MIN_CPU | MEMORY_SIZE | LOG_DISK_SIZE | DATA_DISK_SIZE | MAX_IOPS | MIN_IOPS | IOPS_WEIGHT | MAX_NET_BANDWIDTH | NET_BANDWIDTH_WEIGHT | +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+---------------------+---------------------+-------------+---------------------+----------------------+ | 1003 | S1_unit_config | 2026-09-01 19:56:21.723061 | 2026-09-01 19:56:21.723061 | 1 | 1 | 5368709120 | 5368709120 | 10737418240 | 9223372036854775807 | 9223372036854775807 | 1 | 9223372036854775807 | 1 | +----------------+----------------+----------------------------+----------------------------+---------+---------+-------------+---------------+----------------+---------------------+---------------------+-------------+---------------------+----------------------+ 1 row in set (0.001 sec)
Create a resource pool.
Query the
DBA_OB_RESOURCE_POOLSview for the configuration information of the resource pool.obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_RESOURCE_POOLS;The query result is as follows:
+------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ | RESOURCE_POOL_ID | NAME | TENANT_ID | CREATE_TIME | MODIFY_TIME | UNIT_COUNT | UNIT_CONFIG_ID | ZONE_LIST | REPLICA_TYPE | +------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ | 1 | sys_pool | 1 | 2026-09-01 16:31:19.281405 | 2026-09-01 16:31:19.281405 | 1 | 1 | zone1 | FULL | +------------------+----------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ 1 row in set (0.002 sec)For more information about the
DBA_OB_RESOURCE_POOLSview, see DBA_OB_RESOURCE_POOLS.Use the
CREATE RESOURCE POOLstatement to create a resource pool.Example: Create a resource pool named
mq_pool_01, allocate one unit in zone1, and set the unit's resource specification toS1_unit_config.obclient(root@sys)[oceanbase]> CREATE RESOURCE POOL mq_pool_01 UNIT='S1_unit_config', UNIT_NUM=1, ZONE_LIST=('zone1');For more information about this statement, see the Create a resource pool section in Create a tenant.
Query the
DBA_OB_RESOURCE_POOLSview to confirm that themq_pool_01resource pool has been created successfully.obclient(root@sys)[oceanbase]> SELECT * FROM oceanbase.DBA_OB_RESOURCE_POOLS WHERE NAME = 'mq_pool_01';The query result is as follows:
+------------------+------------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ | RESOURCE_POOL_ID | NAME | TENANT_ID | CREATE_TIME | MODIFY_TIME | UNIT_COUNT | UNIT_CONFIG_ID | ZONE_LIST | REPLICA_TYPE | +------------------+------------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ | 1001 | mq_pool_01 | NULL | 2026-09-01 19:57:25.969501 | 2026-09-01 19:57:25.969501 | 1 | 1003 | zone1 | FULL | +------------------+------------+-----------+----------------------------+----------------------------+------------+----------------+-----------+--------------+ 1 row in set (0.002 sec)
Create a tenant.
Query the
DBA_OB_TENANTSview for all tenant information.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, CREATE_TIME, MODIFY_TIME, PRIMARY_ZONE, LOCALITY, COMPATIBILITY_MODE, STATUS, TENANT_ROLE FROM oceanbase.DBA_OB_TENANTS;The query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+--------------------+--------+-------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | COMPATIBILITY_MODE | STATUS | TENANT_ROLE | +-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+--------------------+--------+-------------+ | 1 | sys | SYS | 2026-09-01 16:31:19.292987 | 2026-09-01 16:31:19.292987 | RANDOM | FULL{1}@zone1 | MYSQL | NORMAL | PRIMARY | +-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+--------------------+--------+-------------+ 1 row in set (0.008 sec)For more information about the
DBA_OB_TENANTSview, see DBA_OB_TENANTS.Use the
CREATE TENANTstatement to create a tenant.Example: Create a tenant named
mq_t1, specify the resource pool asmq_pool_01, set the primary zone to zone1, and allow connections from all IPs to the database.obclient(root@sys)[oceanbase]> CREATE TENANT IF NOT EXISTS mq_t1 PRIMARY_ZONE='zone1', RESOURCE_POOL_LIST=('mq_pool_01') SET OB_TCP_INVITED_NODES='%';For more information about this statement, see the Create a tenant section in Create a tenant.
Query the
DBA_OB_TENANTSview to confirm that themq_t1tenant has been created successfully.obclient(root@sys)[oceanbase]> SELECT TENANT_ID, TENANT_NAME, TENANT_TYPE, CREATE_TIME, MODIFY_TIME, PRIMARY_ZONE, LOCALITY, COMPATIBILITY_MODE, STATUS, TENANT_ROLE FROM oceanbase.DBA_OB_TENANTS WHERE TENANT_NAME = 'mq_t1';The query result is as follows:
+-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+--------------------+--------+-------------+ | TENANT_ID | TENANT_NAME | TENANT_TYPE | CREATE_TIME | MODIFY_TIME | PRIMARY_ZONE | LOCALITY | COMPATIBILITY_MODE | STATUS | TENANT_ROLE | +-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+--------------------+--------+-------------+ | 1002 | mq_t1 | USER | 2026-09-01 20:02:24.186055 | 2026-09-01 20:03:03.737490 | zone1 | FULL{1}@zone1 | MYSQL | NORMAL | PRIMARY | +-----------+-------------+-------------+----------------------------+----------------------------+--------------+---------------+--------------------+--------+-------------+ 1 row in set (0.011 sec)
Step 2: Log in to the user tenant
After the tenant is created, you can log in to it. The default administrator user root of the mq_t1 user tenant has an empty password. You must first change the administrator user's password.
Log in as the root user of the
mq_t1tenant.obclient -h172.30.xx.xx -P2883 -uroot@mq_t1#cluster -AExecute the following statement to change the root user's password.
obclient(root@mq_t1)[(none)]> ALTER USER root IDENTIFIED BY '****'; Query OK, 0 rows affectedAfter the administrator user's password is changed successfully, log in to the tenant again.
obclient -h172.30.xx.xx -P2883 -uroot@mq_t1#cluster -p**** -A
Step 3: Create a business database
Use the
CREATE DATABASEstatement to create a business database.Example: Create a database named
db1, specify the character set asutf8mb4, and set the read/write attribute.obclient(root@mq_t1)[(none)]> CREATE DATABASE db1 DEFAULT CHARACTER SET utf8mb4 READ WRITE;After the database is ceated, you can use the
SHOW DATABASEScommand to view all databases in the current tenant.obclient(root@mq_t1)[(none)]> SHOW DATABASES;The query result is as follows:
+--------------------+ | Database | +--------------------+ | db1 | | information_schema | | mysql | | oceanbase | | test | +--------------------+ 5 rows in set (0.003 sec)For more information about the
CREATE DATABASEstatement, see CREATE DATABASE.
Step 4: Perform basic queries
After the business database is created, you can start using OceanBase AI Database for data writing and querying.
Switch to the
db1database.obclient(root@mq_t1)[(none)]> USE db1;Create a table named
t1to store sample data.obclient(root@mq_t1)[db1]> CREATE TABLE t1 (id INT, name VARCHAR(50), num INT);Insert multiple rows of data into the table
t1.obclient(root@mq_t1)[db1]> INSERT INTO t1 VALUES(1,'a',100),(2,'b',200),(3,'a',50);Query the data in the table
t1.obclient(root@mq_t1)[db1]> SELECT * FROM t1;The query result is as follows:
+------+------+------+ | id | name | num | +------+------+------+ | 1 | a | 100 | | 2 | b | 200 | | 3 | a | 50 | +------+------+------+ 3 rows in set (0.002 sec)Query data by condition. In this example, query records where
name = 'a'.obclient(root@mq_t1)[db1]> SELECT id, name, num FROM t1 WHERE name = 'a';The query result is as follows:
+------+------+------+ | id | name | num | +------+------+------+ | 1 | a | 100 | | 3 | a | 50 | +------+------+------+ 2 rows in set (0.002 sec)
You have now completed your first use of OceanBase AI Database.
References
For more login methods, see Log in to an OceanBase tenant.
Experience the core capabilities of OceanBase AI Database: