Index ¦ Archives ¦ Atom

Simple postgres basics

This is another one of those things I've done all this several times before, but need to keep looking up the documentation.

To login to PostgreSQL after a fresh installation1 you need to change to the postgres user and run psql (no password needed, it uses Peer Authentication)

sudo -u postgres psql

from there you can create a user and access it as you normally would.

createuser -P -s -e michael

to connect to a database use

\c database_name

to list the tables run

\dt

and to make the output format expanded so it fits on a small screen simply switch

\x on

  1. In my case that's usually on Debian or Ubuntu but it should be the same on most Linux distros. 

Creative Commons License
Content on this site is licensed under a Creative Commons Attribution 4.0 International License.
Built using Pelican. Based on a theme by Giulio Fidente on github.