Once you’ve followed the above, to start postgres on system startup, edit /etc/rc.local to add the following line:
setuid postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
To start psql (the postgres client) from the command line as user postgres (root access to the database), type:
sudo -u postgres psql -h localhost
Once you’ve created a database and user as shown above, you can access it by typing:
psql -h localhost -U fsl2002 fsl2002
fsl2002 is my username and database name.
Also, be sure to edit /usr/local/pgsql/data/pg_hba.conf to require some form of authentication, like “md5.” Instructions for doing this are available in the Postgres documentation. If you leave authentication set to “trust,” all users on your local machine will have access to all databases with all users, without using a password! This is a problem because someone could login as user postgres, the root user, with no password, and then change everyone else’s privileges, delete all databases, etc. Good luck!