Easy Tutorial
❮ Postgresql Select Postgresql Join ❯

Installing PostgreSQL on Linux

Open the PostgreSQL official website https://www.postgresql.org/, click on Download in the menu bar, and you will see that it includes installation packages for many platforms, including Linux, Windows, Mac OS, etc.

For Linux, we can see support for various platforms like Ubuntu and Red Hat. Clicking on a specific platform link will show you the installation method:

By clicking on the file browser in the image above, we can also download the latest source code of PostgreSQL.

This section will use Ubuntu as an example.

Installing PostgreSQL on Ubuntu

Ubuntu can install PostgreSQL using apt-get:

sudo apt-get update
sudo apt-get install postgresql postgresql-client

After installation, the system will create a database superuser named postgres with an empty password.

# sudo -i -u postgres

At this point, use the following command to enter postgres, and the following output indicates a successful installation:

~$ psql
psql (9.5.17)
Type "help" for help.

postgres=#

Enter the following command to exit the PostgreSQL prompt:

\q

PostgreSQL is started by default after installation, but you can also manually start the service with the following commands:

sudo /etc/init.d/postgresql start   # Start
sudo /etc/init.d/postgresql stop    # Stop
sudo /etc/init.d/postgresql restart # Restart
❮ Postgresql Select Postgresql Join ❯