首批通过分布式安全可靠测评,为关键业务系统打造
通过 obclient 连接 OceanBase 租户
更新时间:2023-07-17 13:53:43
obclient 是 OceanBase 专用的命令行客户端工具,通过 obclient 您可以连接 OceanBase 的 MySQL 和 ORACLE 租户。
操作步骤
打开一个命令行终端。
参照下面格式提供 obclient 的运行参数:
obclient -h10.0.0.0 -u******@t_oracle0_91#obdoc -P2883 -p**1*** -c -A sys说明
- -h:提供 OceanBase 数据库连接的 IP,通常是一个 OBProxy 地址。
- -u:提供租户的连接帐户,格式有两种:"用户名@租户名#集群名"或者"集群名:租户名:用户名"。Oracle 租户的管理员用户名默认是 sys。
- -P:提供 OceanBase 数据库连接端口,也是 OBProxy 的监听端口,默认是 2883,可以自定义;如果不通过 OBProxy 连接 OceanBase 数据库,而是通过 obclient 直连 OBserver(即 -u 参数中不加"#集群名"),则默认端口是 2881。
- -p:提供帐户密码。为了安全可以不提供,改为在后面提示符下输入,密码文本不可见。
- -c:表示在将 SQL 语句中的注释发往数据库端。
- -A:表示在连接数据库时不去获取全部表信息,可以使登录数据库速度最快。
- sys:访问的数据库名,可以改为业务数据库。
连接成功后,默认会有如下命令行提示符。
obclient>如果要退出 OceanBase 命令行,输入 exit 后回车,或者按快捷键 ctrl + d。
示例
通过 obclient 连接 OceanBase 数据库的 Oracle 租户。
$obclient -h10.0.0.0 -u******@t_oracle0_91#obdoc -P2883 -p**1*** -c -A sys
obclient: [Warning] Using a password on the command line interface can be insecure.
Welcome to the OceanBase monitor. Commands end with ; or \g.
Your OceanBase connection id is 64621
Server version: 5.6.25 OceanBase 2.2.20 (...) (Built Aug 10 2019 15:27:33)
<省略>
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient> select sysdate from dual;
+---------------------+
| SYSDATE |
+---------------------+
| 2020-04-01 21:53:22 |
+---------------------+
1 row in set (0.00 sec)
obclient> exit
Bye