Install PostgreSQL 12 and PgAdmin4 on Ubuntu 18.04.4 LTS

I am going straight forward with commands you need to run in your terminal.

How to install Postgresql in Ubuntu 18.04.4 LTS:

1. Importing GPG key & adding PostgreSQL APT repository
root@vipul-ThinkPad-T440:/# sudo apt install wget ca-certificates

2. Run the command to import the GPG key to your system
root@vipul-ThinkPad-T440:/# wget — quiet -O — https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

3. Append the PostgreSQL apt repository on your system
root@vipul-ThinkPad-T440:# sudo sh -c ‘echo “deb https://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main” >> /etc/apt/sources.list.d/pgdg.list’

4. Update the system repositories before start installing PostgreSQL
root@vipul-ThinkPad-T440:/# sudo apt-get update

5. Run this command to install PostgreSQL 12
root@vipul-ThinkPad-T440:/# sudo apt-get install postgresql postgresql-contrib

6. Connecting to PostgreSQL 12
root@vipul-ThinkPad-T440:/# sudo su — postgres

7. To connect to the PostgreSQL 12 database server use the psql command
postgres@vipul-ThinkPad-T440:~$ psql

8. To check login information, run the command
postgres=# \conninfo (Output-> You are connected to database “postgres” as user “postgres” via socket in “/var/run/postgresql” at port “5432”.)

9. Change the password for user postgres
postgres=# \password postgres
Output-(Enter new password:
Enter it again:)

How to Install PgAdmin4 in Ubuntu 18.04.4 LTS:

  1. vipul@vipul-ThinkPad-T440:~$ sudo apt-get install pgadmin4 pgadmin4-apache2
  2. During the installation process, you will be prompted for an email address and password to provide your preferred ones.
    After installation open the browser in my case: http://127.0.0.1:38727/browser/

Software Developer