psql
Get a prompt
psql postgresql://postgres:postgres@localhost:5432/postgres
postgresql://user:secret@localhost/DB_Name
psql postgresql://user:user@localhost/postgres
postgresql://user:secret@localhost/DB_Name
psql postgresql://wikijs@localhost:5432/wiki
psql -h <endpoint> -U <userid> -d <databasename> -p <port>
List Databases
\l
List PostgreSQL databases
Load in a file
psql --set ON_ERROR_STOP=on -U user -h 127.0.0.1 -p 5432 -d mydb < gem_2021-12-14.sql
## To Test
sudo -u postgres psql -d myDataBase -a -f myInsertFile
Key Commands
- List Databases
\l
- Connect Database
\c database_name
- List Tables in current database
\dt
Sources
Backlinks