Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Connect to PostgreSQL
#1


    How to Connect to PostgreSQL

   

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.

   

   

Reply


Messages In This Thread
How to Connect to PostgreSQL - by aaron - 09-08-2023, 01:13 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)