In una finestra del terminale, avvia psql e specifica localhost come host del server di database.
Se vuoi, specifica un numero di porta se PGAdapter è configurato per ascoltare su una porta diversa dalla porta PostgreSQL predefinita (5432).
Se vuoi, specifica uno o più comandi da inviare al database o al driver
(ad esempio, il driver JDBC). Per ogni occorrenza dell'opzione -c, puoi specificare un singolo comando o un batch di comandi separati da punti e virgola (;). Per ulteriori informazioni, consulta lo strumento a riga di comando psql.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-05 UTC."],[],[],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)."]]