RadonDB 推荐使用内网地址连接数据库,确保数据传输速率的同时兼顾数据安全。

本小节主要介绍如何连接 RadonDB 数据库,以终端命令行方式连接数据库。

前提条件

  • 已获取管理工作台登录账号和密码,且已获取集群操作权限。

  • 已创建 RadonDB 集群,且集群状态为活跃

  • 已在服务器安装 MySQL 客户端。

操作步骤

获取连接信息

  1. 登录管理控制台。

  2. 选择产品与服务 > 数据库与缓存 > 分布式数据库 RadonDB,进入集群管理页面。

  3. 选择目标集群,点击目标集群 ID,进入集群详情页面。

  4. 服务端口信息模块,获取高可用 IP 地址。

    连接信息
  5. 账号页签,获取数据库账号。

    连接账号

访问数据库

通过命令连接方式如下:

mysql -h <mysqlServerName> -P <port> -u <userName> -p -D <databaseName>
选项 说明 示例

-h

数据库高可用 IP 地址。

192.168.0.229

-P

数据库端口号。

3306

-u

用户账号名称。

test_radondb

-p

用户账号密码。

  • 为保障密码安全,-p一般空密码。在执行命令后输入密码,回车即可。

  • 若需填写该参数,-p与密码之间不能有空格。

test_mysql

-D

数据库名称。非必填参数;可不输入-D ,仅输入数据库名称。

mysql

回显示例

$ mysql -h 192.168.0.229 -P <3306> -u test_radondb -p
Enter password:
Welcome to the MySQL monitor.   Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.24 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademark of their respective owners.

Type 'help;' or'\h' for help. Type '\c' to clear the current input statement.

mysql>