---
title: OceanBase 数据库的三段式用户名格式与大小写敏感度-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于OceanBase 数据库的三段式用户名格式与大小写敏感度相关的常见问题和使用技巧，帮助您快速解决OceanBase 数据库的三段式用户名格式与大小写敏感度的难题。
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

划线反馈

# OceanBase 数据库的三段式用户名格式与大小写敏感度

更新时间：2026-07-02 15:41

适用版本： V2.1.x、V2.2.x、V3.1.x、V3.2.x、V4.0.x、V4.1.x、V4.2.x 内容类型：TechNote  

本文主要介绍连接 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 模式租户的三段式用户名格式中的用户名、租户名、集群名都是大小写敏感的。

  ```shell
  ## -- 采用了用户名、租户名连接 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

  ```

  ```shell
  ## -- 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)

  ```

  ```shell
  ## -- 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)

  ```

  ```shell
  ## -- 采用了用户名、租户名集群名、连接 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)

  ```

  ```shell
  ## -- 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)

  ```

  ```shell
  ## -- tenantname 变换大小写
  $ mysql -h127.0.0.1 -uroot@MySQL#oio_cluster -P2883 -pxxx
  ERROR 4012 (HY000): Get Location Cache Fail

  ```

  ```shell
  ## -- clustername 变换大小写
  $ mysql -h127.0.0.1 -uroot@mysql#Oio_cluster -P2883 -pxxx
  ERROR 4669 (HY000): cluster not exist

  ```
 - Oracle 模式租户中仅狭义的 username 不区分大小写，其它所有的字段都大小写敏感的。

  ```shell
  ## -- 采用了用户名、租户名连接 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.

  obclient [SYS]> Bye

  ```

  ```shell
  ## -- 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)

  ```

  ```shell
  ## -- 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)

  ```

  ```shell
  ## -- 采用了用户名、租户名集群名、连接 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)

  ```

  ```shell
  ## -- 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)

  ```

  ```shell
  ## -- tenantname 变换大小写
  $ obclient -h127.0.0.1 -P2883 -usys@Oracle#oio_cluster -pxxx
  ERROR 4012 (HY000): Get Location Cache Fail

  ```

  ```shell
  ## -- clustername 变换大小写
  $ obclient -h127.0.0.1 -P2883 -usys@oracle#Oio_cluster -pxxx
  ERROR 4669 (HY000): cluster not exist

  ```

## 通过 OCP 创建集群、租户时的大小写敏感度

- 在同一个 OCP 下不支持创建两个同名的 OceanBase 主集群（即使集群名大小写不一致也不行）：

  ![image001](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/knowledge-base/database/sql/20240606obusernametenantcluster001.png)
 - 在同一个 OCP 里面的同一个 OceanBase 集群中，不支持创建同名的租户（即使租户名大小写不一致也不行）：

  ![image002](https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/doc/img/knowledge-base/database/sql/20240606obusernametenantcluster002.png)

## 适用版本

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

上一篇

[OceanBase 数据库 V4.x 版本中 Location Service 问题排查](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000941489)

下一篇

[仲裁节点 observer.log 日志增长过快的原因及解决方法](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000002942491) ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
