104 lines
2.1 KiB
Markdown
104 lines
2.1 KiB
Markdown
通过 MySQL 客户端连接 OceanBase 租户
|
|
================================================
|
|
|
|
|
|
|
|
需要使用 OceanBase 的 MySQL 租户时,可以使用 MySQL 客户端连接该租户。
|
|
|
|
### 操作步骤如下:
|
|
|
|
1. 打开一
|
|
|
|
个命令行终端,确保环境变量 PATH 包含了 MySQL 客户端命令所在目录。
|
|
|
|
|
|
2. 参照下面格式提供 MySQL 的运行参数:
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
$mysql -h192.168.1.101 -uroot@obmysql#obdemo -P2883 -pabcABC123 -c -A oceanbase
|
|
```
|
|
|
|
|
|
**说明**
|
|
|
|
|
|
|
|
* -h:提供 OceanBase 数据库连接 IP,通常是一个 OBProxy 地址。
|
|
|
|
|
|
|
|
* -u:提供租户的连接账户,格式有两种:用户名@租户名#集群名 或者 集群名:租户名:用户名 。MySQL 租户的管理员用户名默认是 root 。
|
|
|
|
|
|
|
|
* -P:提供 OceanBase 数据库连接端口,也是 OBProxy 的监听端口,默认是2883,可以自定义。
|
|
|
|
|
|
|
|
* -p:提供账户密码,为了安全可以不提供,改为在后面提示符下输入,密码文本不可见。
|
|
|
|
|
|
|
|
* -c:表示在 MySQL 运行环境中不要忽略注释。
|
|
|
|
|
|
|
|
* -A:表示在 MySQL 连接数据库时不自动获取统计信息。
|
|
|
|
|
|
|
|
* oceanbase:访问的数据库名,可以改为业务数据库。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3. 连接成功后,默认会有命令行提示符:
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
MySQL [oceanbase]>
|
|
```
|
|
|
|
|
|
|
|
4. 如果要退出 OceanBase 命令行,输入 exit 后回车,或者按快捷键 ctrl + d。
|
|
|
|
|
|
|
|
|
|
### 如下示例为通过 MySQL 客户端连接 OceanBase 的 MySQL 租户。
|
|
|
|
```javascript
|
|
$mysql -h192.168.1.101 -uroot@obmysql#obdemo -P2883 -pabcABC123 -c -A oceanbase
|
|
Welcome to the MariaDB monitor. Commands end with ; or \g.
|
|
Your MySQL connection id is 62488
|
|
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.
|
|
|
|
MySQL [oceanbase]> show databases;
|
|
+--------------------+
|
|
| Database |
|
|
+--------------------+
|
|
| oceanbase |
|
|
| information_schema |
|
|
| mysql |
|
|
| test |
|
|
+--------------------+
|
|
4 rows in set (0.00 sec)
|
|
|
|
MySQL [oceanbase]> exit
|
|
Bye
|
|
```
|
|
|
|
|