09-08-2023, 01:13 PM
During the installation, PostgreSQL automatically creates the default postgres role for logging in to the database. To switch to this user, run the following command:
sudo su - postgres
Your command line should now begin with postgres. To connect to the PostgreSQL database, use the PostgreSQL shell using the following:
sudo psql
The psql command will create a session in the default database. If the command isn’t found, manually install the PostgreSQL client using this command:
sudo apt-get install postgresql-client
To check the connection status, run this command using the PostgreSQL prompt:
\conninfo

To quit the PostgreSQL prompt and return to the regular system user, use the exit command. Meanwhile, use \q to detach from the database’s interactive session.

