首批通过分布式安全可靠测评,为关键业务系统打造
OceanBase 数据库的三段式用户名格式与大小写敏感度
更新时间:2026-07-02 15:41
本文主要介绍连接 OceanBase 数据库时使用的三段式用户名格式以及用户名、租户名、集群名的大小写敏感度。
三段式用户名格式
由于不同于传统的 MySQL、Oracle 数据库,OceanBase 是一个多租户架构的分布式集群数据库,同一个 OceanBase 集群可以同时支持运行多个租户,以支持不同的业务应用。在 OceanBase 数据库中,一个租户等价于传统数据库的一个实例,而分布式架构则依赖于 OBProxy 做正确的 SQL 路由和转发。由于一套 OBProxy 集群支持连接多个 OceanBase 的集群,因此通过 OBProxy IP 地址访问 OceanBase 服务时,一般都需要指定具体的用户名+租户名+集群名,三段式格式有四种,具体如下:
username@tenantname#clustername例如:root@trade#xxbank。clustername:tenantname:username例如:xxbank:trade:root。clustername-tenantname-username例如:xxbank-trade-root。clustername.tenantname.username例如:xxbank.trade.root。
如果这边的 OceanBase 集群还有备集群的话,往往还需要在 clustername 后面添加 cluster_id,用于区分具体连接的是主集群还是备集群(默认不加 cluster_id 连接的都是主业务集群)。
大小写敏感度
MySQL 模式租户的三段式用户名格式中的用户名、租户名、集群名都是大小写敏感的。
## -- 采用了用户名、租户名连接 OceanBase 数据库 $ mysql -h127.0.0.1 -uroot@mysql -P2881 -pxxx Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 3221583835 Server version: 5.7.25 OceanBase 3.2.4.8 (r108000142024041520-41146481be6d9aa69b30d14e4382ab2c4d2d5235) (Built Apr 15 2024 20:33:10) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> Bye## -- username 变换大小写 $ mysql -h127.0.0.1 -uROOT@mysql -P2881 -pxxx ERROR 1045 (42000): Access denied for user 'ROOT'@'xxx.xxx.xxx.xxx' (using password: YES)## -- tenantname 变换大小写 $ mysql -h127.0.0.1 -uroot@MySQL -P2881 -pxxx ERROR 1045 (42000): Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES)## -- 采用了用户名、租户名集群名、连接 OceanBase 数据库 $ mysql -h127.0.0.1 -uroot@mysql#oio_cluster -P2883 -pxxx Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 69124 Server version: 5.6.25 OceanBase 3.2.4.8 (r108000142024041520-41146481be6d9aa69b30d14e4382ab2c4d2d5235) (Built Apr 15 2024 20:33:10) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> Bye## -- username 变换大小写 $ mysql -h127.0.0.1 -uROOT@mysql#oio_cluster -P2883 -pxxx ERROR 1045 (42000): Access denied for user 'ROOT'@'xxx.xxx.xxx.xxx' (using password: YES)## -- tenantname 变换大小写 $ mysql -h127.0.0.1 -uroot@MySQL#oio_cluster -P2883 -pxxx ERROR 4012 (HY000): Get Location Cache Fail## -- clustername 变换大小写 $ mysql -h127.0.0.1 -uroot@mysql#Oio_cluster -P2883 -pxxx ERROR 4669 (HY000): cluster not existOracle 模式租户中仅狭义的 username 不区分大小写,其它所有的字段都大小写敏感的。
## -- 采用了用户名、租户名连接 OceanBase 数据库 $ obclient -h127.0.0.1 -P2881 -usys@oracle -pxxx Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221595493 Server version: OceanBase 3.2.4.8 (r108000142024041520-41146481be6d9aa69b30d14e4382ab2c4d2d5235) (Built Apr 15 2024 20:33:10) 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 [SYS]> Bye## -- username 变换大小写 $ obclient -h127.0.0.1 -P2881 -uSys@oracle -pxxx Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 3221597715 Server version: OceanBase 3.2.4.8 (r108000142024041520-41146481be6d9aa69b30d14e4382ab2c4d2d5235) (Built Apr 15 2024 20:33:10) 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 [SYS]> Bye## -- tenantname 变换大小写 $ obclient -h127.0.0.1 -P2881 -usys@Oracle -pxxx ERROR 1045 (42000): Access denied for user 'sys'@'xxx.xxx.xxx.xxx' (using password: YES)## -- 采用了用户名、租户名集群名、连接 OceanBase 数据库 $ obclient -h127.0.0.1 -P2883 -usys@oracle#oio_cluster -pxxx Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 69626 Server version: OceanBase 3.2.4.8 (r108000142024041520-41146481be6d9aa69b30d14e4382ab2c4d2d5235) (Built Apr 15 2024 20:33:10) 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 [SYS]> Bye## -- username 变换大小写 $ obclient -h127.0.0.1 -P2883 -uSys@oracle#oio_cluster -pxxx Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 69636 Server version: OceanBase 3.2.4.8 (r108000142024041520-41146481be6d9aa69b30d14e4382ab2c4d2d5235) (Built Apr 15 2024 20:33:10) 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 [SYS]> Bye## -- tenantname 变换大小写 $ obclient -h127.0.0.1 -P2883 -usys@Oracle#oio_cluster -pxxx ERROR 4012 (HY000): Get Location Cache Fail## -- clustername 变换大小写 $ obclient -h127.0.0.1 -P2883 -usys@oracle#Oio_cluster -pxxx ERROR 4669 (HY000): cluster not exist
通过 OCP 创建集群、租户时的大小写敏感度
在同一个 OCP 下不支持创建两个同名的 OceanBase 主集群(即使集群名大小写不一致也不行):

在同一个 OCP 里面的同一个 OceanBase 集群中,不支持创建同名的租户(即使租户名大小写不一致也不行):

适用版本
OceanBase 数据库 V2.x、V3.x、V4.x 版本。