Postgres Installation

Topics

Source:

Change the password for the postgres Linux account. Choose a strong password and store it in a secure place.

sudo passwd postgres

Switch over to the postgres account.

su - postgres

Change the password for the postgres PostgreSQL user to use when connecting over a network.

psql -c "ALTER USER postgres WITH PASSWORD 'newpassword'"

Check all installed Extensions

\dx

From the Linux shell, while logged in as postgres, create a test database using the createdb command.

createdb testdatabase

Connect to the new database directly.

psql testdatabase

List all of the databases in the cluster with the \l meta-command.

\l

Check currently logged in user

\conninfo

While you are logged into PostgreSQL, you can switch to a different database using the \c meta-command.

\c testdatabase

Run the command from the Linux shell while logged in as postgres.


dropdb testdatabase

List all of the tables in the database with the \dt meta-command.

\dt