[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-05。"],[],[],null,["# Connect psql to a PostgreSQL-dialect database\n\nThis page explains how to connect `psql` to a PostgreSQL-dialect database in Spanner.\n`psql` is the command-line front end to PostgreSQL.\n\n1. Ensure that PGAdapter is running on the same machine as the `psql` command.\n\n For more information, see [Start PGAdapter](/spanner/docs/pgadapter-start).\n2. In a terminal window, start `psql` and specify `localhost` as the database server host.\n\n - Optionally specify a port number if PGAdapter is configured to listen on a port other than the default PostgreSQL port (5432).\n - Optionally specify one or more commands to send to the database or driver (for example, the JDBC driver). For each occurrence of the `-c` option, you can specify a single command or a batch of commands separated by semicolons (;). For more information, see [psql command-line tool](/spanner/docs/psql-commands).\n\n `psql -h localhost [-p `\u003cvar translate=\"no\"\u003ePORT\u003c/var\u003e`] [-c \"`\u003cvar translate=\"no\"\u003eCOMMAND\u003c/var\u003e`; ...\"] ...`\n3. Optional: Verify that `psql` successfully connected to a PostgreSQL-dialect database\n by submitting the following query:\n\n `SELECT 1::bigint;`\n\n This query is incompatible with GoogleSQL-dialect databases.\n\nWhat's next\n-----------\n\n- Learn about [PGAdapter](/spanner/docs/pgadapter).\n- See the supported `psql` commands in [psql command-line tool](/spanner/docs/psql-commands)."]]