How to Install PostgreSQL on Ubuntu 18.04


Easily deploy your favorite applications in seconds at an unbeatable price for your next projects.

Installing PostgreSQL on Ubuntu 18.04

PostgreSQL is a powerful, open-source object-relational database system that is known for its reliability, flexibility, and scalability. It provides advanced features like full-text search, geospatial support, and extensibility through its extension framework. In this guide, we will walk you through the installation process of PostgreSQL on Ubuntu 18.04.

Step 1: Update System Packages

Before installing any software, it's important to update the system packages to their latest versions. Open a terminal and run the following command:

sudo apt update

Step 2: Install PostgreSQL

Once the system packages are updated, you can proceed with the installation of PostgreSQL. Run the following command in the terminal:

sudo apt install postgresql

Step 3: Verify Installation

After the installation is complete, you can verify it by checking the version of PostgreSQL. Run the following command:

psql --version

Step 4: Access PostgreSQL

By default, PostgreSQL creates a system user named "postgres" during the installation. You can switch to the "postgres" user and access the PostgreSQL shell using the following command:

sudo su - postgres

You can now use commands like "psql" to interact with the PostgreSQL database.

Step 5: Create a New User and Database

To create a new user and database in PostgreSQL, you can follow these steps:

  1. Switch to the "postgres" user: sudo su - postgres
  2. Access the PostgreSQL shell: psql
  3. Create a new user: CREATE USER myuser WITH PASSWORD 'mypassword';
  4. Create a new database: CREATE DATABASE mydatabase OWNER myuser;
  5. Grant all privileges to the user on the database: GRANT ALL PRIVILEGES ON DATABASE mydatabase TO myuser;
  6. Exit the PostgreSQL shell: \q

Step 6: Start/Stop/Restart PostgreSQL

To start, stop, or restart the PostgreSQL service on Ubuntu, you can use the following commands:

  • Start PostgreSQL: sudo service postgresql start
  • Stop PostgreSQL: sudo service postgresql stop
  • Restart PostgreSQL: sudo service postgresql restart


Congratulations! You have successfully installed PostgreSQL on Ubuntu 18.04. You can now use PostgreSQL to build and manage powerful databases for your applications.

Refer A Friend
Get $25

Installing PostgreSQL
Ubuntu 18.04
PostgreSQL installation
PostgreSQL setup
Postgres installation
Postgres setup
Ubuntu PostgreSQL installation
Ubuntu PostgreSQL setup
Installing PostgreSQL on Ubuntu
Ubuntu 18.04 PostgreSQL installation

Why Customers Love Us

What our customers say about us

Ready To Get Started For Free?

Create your free account today.