+3 votes
in Databases by (40.5k points)
What command should I use to install PostgreSQL on Ubuntu 20?

After installing PostgreSQL, how can I access it from the command line?

1 Answer

+1 vote
by (353k points)
selected by
Best answer

Ubuntu’s default repositories contain PostgreSQL packages, so you can install them using the "apt install" command.

Step 1: Update your local package repository.

$ sudo apt-get update

Step 2: Install the postgres package. You can also install postgresql-contrib package that adds some additional utilities and functionality.

$ sudo apt install postgresql postgresql-contrib

The PostgreSQL is now installed. To access it from the command line, run the following command:

$ sudo -u postgres psql postgres

This will log you into the PostgreSQL prompt. You can run your SQLs there.

psql (12.6 (Ubuntu 12.6-0ubuntu0.20.04.1))
Type "help" for help.


Related questions

+4 votes
1 answer
+1 vote
1 answer
asked Jul 10, 2023 in Databases by phpuser (59.8k points)
+2 votes
1 answer