netbsd
createdb -e -h 127.0.0.1 -U pgsql nobudget psql -U pgsql nobudget
slackware
createdb -e -h 127.0.0.1 -U postgres nobudget psql -U postgres nobudget
or
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';" sudo -u postgres psql -c "CREATE DATABASE testdb;"
or yet another way
psql -U postgres create database nobudget;
and create a user
create user nobudget with encrypted password 'PASSWORD-HERE'; grant all privileges on database nobudget to nobudget; ^D
psql -h HOST -p PORT -U DBUSER # -d DBNAME
list databases
\list
pick one
\c DBNAME
list tables
\dt
write output to file
\o out.txt select * from TABLE; \o ^D
as CSV
psql --csv ... \o out.csv select * from TABLE; \o ^D
https://dba.stackexchange.com/questions/1285/how-do-i-list-all-databases-and-tables-using-psql
https://stackoverflow.com/questions/5331320/psql-save-results-of-command-to-a-file