2.1 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			2.1 KiB
		
	
	
	
	
	
	
	
通过 obclient 连接 OceanBase 租户
obclient 是 OceanBase 专用的命令行客户端工具,通过 obclient 您可以连接 OceanBase 的 MySQL 和 ORACLE 租户。
操作步骤如下:
- 
打开一个命令行终端。 
- 
参照下面格式提供 obclient 的运行参数: 
$ obclient -h192.168.1.101 -uroot@obmysql#obdemo -P2883 -pabcABC123 -c -A oceanbase
说明
- 
-h:提供 OceanBase数据库连接的IP,通常是一个 OBProxy 地址。 
- 
-u:提供租户的连接帐户,格式有两种:"用户名@租户名#集群名"或者"集群名:租户名:用户名"。Oracle 租户的管理员用户名默认是sys。 
- 
-P:提供 OceanBase 数据库连接端口,也是 OBProxy 的监听端口,默认是 2883,可以自定义。 
- 
-p:提供帐户密码。为了安全可以不提供,改为在后面提示符下输入,密码文本不可见。 
- 
-c:表示在将 SQL 语句中的注释发往数据库端。 
- 
-A:表示在连接数据库时不去获取全部表信息,可以使登录数据库速度最快。 
- 
oceanbase:访问的数据库名,可以改为业务数据库 
- 连接成功后,默认会有如下命令行提示符。
obclient>
- 
如果要退出 OceanBase 命令行,输入 exit 后回车,或者按快捷键 ctrl + d。 以下示例为通过 obclient 连接 OceanBase 的 MySQL 租户。 
$obclient -h192.168.1.101 -uroot@obmysql#obdemo -P2883 -pabcABC123 -c -A oceanbase
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();
+---------------------+
| sysdate()                  |
+---------------------+
| 2020-04-01 21:53:22 |
+---------------------+
1 row in set (0.00 sec)
obclient> exit
Bye
