Difference between revisions of "Psql"
Jump to navigation
Jump to search
Line 16: | Line 16: | ||
*<code>psql -h <REMOTE HOST> -p <REMOTE PORT> -U <DB_USER> <DB_NAME></code> | *<code>psql -h <REMOTE HOST> -p <REMOTE PORT> -U <DB_USER> <DB_NAME></code> | ||
+ | ===Other examples=== | ||
if database is defined in <code>[[.pg_service.conf]]</code> you can use: | if database is defined in <code>[[.pg_service.conf]]</code> you can use: | ||
[[psql]] service=MyDB | [[psql]] service=MyDB | ||
− | |||
psql | psql | ||
psql: FATAL: [[role]] "root" does not exist | psql: FATAL: [[role]] "root" does not exist | ||
− | |||
[[su - postgres]] && psql | [[su - postgres]] && psql | ||
Line 37: | Line 36: | ||
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one. | Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one. | ||
Error: You must install at least one postgresql-client-<version> package | Error: You must install at least one postgresql-client-<version> package | ||
− | |||
FATAL: no [[pg_hba.conf]] entry for host "1x.1xx.2xx.1xx", user "your_username", database "your_db_name", SSL off | FATAL: no [[pg_hba.conf]] entry for host "1x.1xx.2xx.1xx", user "your_username", database "your_db_name", SSL off | ||
Line 50: | Line 48: | ||
Is the server running on host "your_rds_instance.eu-central-1.[[rds.amazonaws.com]]" (7.123.109.22) and accepting | Is the server running on host "your_rds_instance.eu-central-1.[[rds.amazonaws.com]]" (7.123.109.22) and accepting | ||
TCP/IP connections on port [[5433]] ? | TCP/IP connections on port [[5433]] ? | ||
− | |||
psql | psql | ||
Password for user YOUR_USERNAME: | Password for user YOUR_USERNAME: |
Revision as of 12:46, 20 September 2021
Installation
- Ubuntu installation:
apt install postgresql-client-12
sudo -u postgres psql psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1)) Type "help" for help. postgres=#
psql --host=mypostgresql.c6c8mwvfdgv0.us-west-2.rds.amazonaws.com --port=5432 --username=awsuser --password --dbname=mypgdb
psql -h localhost -U YOUR_USERNAME DB_NAME
psql -h <REMOTE HOST> -p <REMOTE PORT> -U <DB_USER> <DB_NAME>
Other examples
if database is defined in .pg_service.conf
you can use:
psql service=MyDB
psql psql: FATAL: role "root" does not exist
su - postgres && psql psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1)) Type "help" for help. postgres=#
sudo -u postgres psql could not change directory to "/root": Permission denied psql (12.6 (Ubuntu 12.6-0ubuntu0.20.04.1)) Type "help" for help.
psql Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one. Error: You must install at least one postgresql-client-<version> package
FATAL: no pg_hba.conf entry for host "1x.1xx.2xx.1xx", user "your_username", database "your_db_name", SSL off
psql psql: error: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
psql service=pro psql: error: could not connect to server: Connection refused Is the server running on host "your_rds_instance.eu-central-1.rds.amazonaws.com" (7.123.109.22) and accepting TCP/IP connections on port 5433 ? psql Password for user YOUR_USERNAME: psql: error: FATAL: password authentication failed for user "YOUR_USERNAME" FATAL: no pg_hba.conf entry for host "xx.xx.xx.xx", user "YOUR_USERNAME", database "YOUR_DATABASE", SSL off
Options
- Port (
-p
):psql -p 5432
Related terms
pg_hba.conf
(PostgreSQL Client Authentication Configuration File)apt install postgresql
.psqlrc
- Connect to a database
- Show databases
- Create database
- Delete database
- Create user
- List users
- List databases
- List tables:
show tables
- GRANT
aws rds describe-db-instances
See also
- PostgreSQL:
psql
,.psqlrc, .pgpass
,$HOME/.pg service.conf
,-U, -W, -d
, meta-commands:\du, \dg, \ddp, \dp, \list, \dn, \dt, \c, \l, \di, \q
,show users
,show
,su - postgres
,psql -c, \?, \connect, \conninfo
,--version, --help
, PL/pgSQL - PostgreSQL:
pg_dump, pg_restore
,pgAdmin, pg_config, psql, pg_ctl, pg_isready, initdb
, Role, Schema, DBeaver, Navicat, DataGrip, OmniDB,Adminer
, docker-compose.xml PostgreSQL, PostgreSQL version, PostgreSQL logs,postgresql.conf
,pg_hba.conf, $HOME/.pg_service.conf
, Create database (PostgreSQL), Create user,createdb
,GRANT
,pg_stat
, PostgreSQL VACUUM, EXPLAIN,pg stat activity
, Autovacuum, ALTER DATABASE, PostgreSQL statistics collector, Shared buffers, EXPLAIN (PostgreSQL),EXPLAIN ANALYZE
, Bitmap scan,EXPLAIN VERBOSE
,EXPLAIN VERBOSE (PostgresSQL)
,WAL
,ALTER USER
,CREATE ROLE, CREATE USER
,\du
,show users
,\l
, The Statistics Collector, pganalyze,cron.schedule
, Master,pg_tables
, PostgreSQL replication,CREATE, SET
, TOAST, PgBouncer, Restore DB, Index, meta-commands, Table, foreign table, Schema, Sequence, Views, materialized view, Table Partitioning, monitoring, PostgreSQL System Administration Functions, PostgreSQL extension, privileges, logging, PGTune, PostgreSQL parameter tunning, PostgreSQL modules, pgbench, PostgreSQL users, catalogs
Advertising: