在集群主机上,默认安装了adb客户端,可以直接使用。如果需要在集群之外的主机上通过adb登录,则需要安装对应的antdb客户端。
通过adb --help命令可以得到adb的帮助信息:
adb is the PostgreSQL interactive terminal.
Usage:
adb [OPTION]... [DBNAME [USERNAME]]
General options:
-c, --command=COMMAND run only single command (SQL or internal) and exit
-d, --dbname=DBNAME database name to connect to (default: "danghb")
-f, --file=FILENAME execute commands from file, then exit
-l, --list list available databases, then exit
-v, --set=, --variable=NAME=VALUE
set adb variable NAME to VALUE
(e.g., -v ON_ERROR_STOP=1)
-V, --version output version information, then exit
-X, --no-adbrc do not read startup file (~/.adbrc)
-1 ("one"), --single-transaction
execute as a single transaction (if non-interactive)
-?, --help[=options] show this help, then exit
--help=commands list backslash commands, then exit
--help=variables list special variables, then exit
Input and output options:
-a, --echo-all echo all input from script
-b, --echo-errors echo failed commands
-e, --echo-queries echo commands sent to server
-E, --echo-hidden display queries that internal commands generate
-L, --log-file=FILENAME send session log to file
-n, --no-readline disable enhanced command line editing (readline)
-o, --output=FILENAME send query results to file (or |pipe)
-q, --quiet run quietly (no messages, only query output)
-s, --single-step single-step mode (confirm each query)
-S, --single-line single-line mode (end of line terminates SQL command)
Output format options:
-A, --no-align unaligned table output mode
-F, --field-separator=STRING
field separator for unaligned output (default: "|")
-H, --html HTML table output mode
-P, --pset=VAR[=ARG] set printing option VAR to ARG (see \pset command)
-R, --record-separator=STRING
record separator for unaligned output (default: newline)
-t, --tuples-only print rows only
-T, --table-attr=TEXT set HTML table tag attributes (e.g., width, border)
-x, --expanded turn on expanded table output
-z, --field-separator-zero
set field separator for unaligned output to zero byte
-0, --record-separator-zero
set record separator for unaligned output to zero byte
Connection options:
-h, --host=HOSTNAME database server host or socket directory (default: "local socket")
-p, --port=PORT database server port (default: "5432")
-U, --username=USERNAME database user name (default: "danghb")
-w, --no-password never prompt for password
-W, --password force password prompt (should happen automatically)
For more information, type "\?" (for internal commands) or "\help" (for SQL
commands) from within adb, or consult the adb section in the PostgreSQL
documentation.
Report bugs to <pgsql-bugs@antdbql.org>.其中我们需要我们重点关注的是:
-h指定数据库服务器的主机名称或者IP-p指定数据库服务的端口-d指定需要连接的数据库名称-U指定需要连接的数据库用户名
一个完整的示例如下:
adb -h 192.168.1.1 -p 5432 -d antdb -U antdb如果服务端对连接客户端设置了trust认证,则可以直接登录,如果设置了md5认证,则会提示输入密码:
Password for user antdb:按照提示输入密码即可。
登录成功提示符:
adb (4.0.0 cbabf9feaf based on PG 10.7)
Type "help" for help.
antdb=#可以通过更换-h和-p的参数值来连接集群中不同的coord节点。
集群中各个coord节点提供的功能都是一样的,后续操作登录任意coord节点均可。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




