合 如何连接OceanBase租户
如何连接OceanBase租户?
https://open.oceanbase.com/docs/tutorials/quickstart/V1.0.0/3-3-how-to-connect-tenants
OceanBase 开源版的租户只兼容 MySQL ,连接协议兼容 MySQL 5.6 。因此 MySQL 命令行客户端或者图形化工具理论上也是能连接 OceanBase 的租户。此外,OceanBase 也提供专属的命令行客户端工具 OBCLIENT 和图形化客户端工具 ODC 。
MYSQL 客户端连接
OceanBase MySQL 租户支持传统 MySQL 客户端连接,连接方式基本不变,跟传统 MySQL 不一样的地方是用户名的格式。
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | mysql -h172.20.249.50 -uroot@sys#obdemo -P2883 -p4S9wDbSr -c -A oceanbase Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 13 Server version: 5.6.25 OceanBase 3.1.0 (r3-b20901e8c84d3ea774beeaca963c67d7802e4b4e) (Built Aug 10 2021 08:10:38) 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 [oceanbase]> show databases; +--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | SYS | | LBACSYS | | ORAAUDITOR | | test | +--------------------+ 7 rows in set (0.008 sec) |
备注:
-h
:提供 OceanBase 数据库连接 IP,通常是一个 OBProxy 地址。-u
:提供租户的连接账户,格式有两种:用户名@租户名#集群名
或者集群名:租户名:用户名
。MySQL 租户的管理员用户名默认是 root 。-P
:提供 OceanBase 数据库连接端口,也是 OBProxy 的监听端口,默认是2883,可以自定义。-p
:提供账户密码,为了安全可以不提供,改为在后面提示符下输入,密码文本不可见。-c
:表示在 MySQL 运行环境中不要忽略注释。-A
:表示在 MySQL 连接数据库时不自动获取统计信息。- oceanbase:访问的数据库名,可以改为业务数据库。
新创建的业务租户的管理员(root
)密码默认是空的。需要改密码。