Install PostgreSQL 10 on Ubuntu

28/12/2020

Install PostgreSQL 10 on Ubuntu 17.10

PostgreSQL is an open source database that is widely used all over the world. The latest version of PostgreSQL is 10.  In this article I will show you how to install PostgreSQL 10 on Ubuntu 17.10 Artful Aardvark. Let’s get started.  First go to the official website of PostgreSQL, https://www.postgresql.org and you should see the following window. Click on “Download” as shown in the screenshot below.

You should see the following window. Now click on “Ubuntu” as shown in the screenshot.

You should see the following page. The marked section is the line that you should add into /etc/apt/sources.list file. Select the line and copy it.

Now open a terminal by pressing Ctrl+Alt+T or from the Applications menu. Run the following command to edit the /etc/apt/sources.list file. I am using nano text editor here. If you want, you can use vim or whatever you like.

$ sudo nano /etc/apt/sources.list

You should see the following window. This is where you should paste the line that you just copied.

Press the arrow keys to move the cursor to an empty location. Then press the right mouse button and click on “Paste” to paste the line you just copied.

Now change ‘YOUR_UBUNTU_VERSION_HERE-pgdg’ to ‘zesty-pgdg’. PostgreSQL 10 is not available for Ubuntu 17.10 Artful Aardvark yet. So I added the repository for Ubuntu 17.04 Zesty Zapus. It works pretty well.

Once everything is done, the file should look like this. Now press Ctrl+X, then press ‘y’ and press <Enter> to save the file.

Now we have to add the GPG key of PostgreSQL on Ubuntu 17.10. Copy the following line from the Ubuntu download page of PostgreSQL website.

Open a terminal and press the right mouse button and click on “Paste” as shown in the screenshot.

This is how it should look now. Press <Enter> to run the command.

You can see that the GPG key is added.

Now we have to update the package repository cache of our Ubuntu operating system. Run the following command to do that:

$ sudo apt-get update

At this point, we are ready to install PostgreSQL 10. Run the following command to install PostgreSQL 10:

$ sudo apt-get install postgresql-10

Once you run the command, you should see the following window. Just press ‘y’ and then press <Enter> to continue.

The installation should be complete in a while.

Once the installation is complete, run the following command to check whether PostgreSQL is running or not.

$ sudo systemctl status postgresql

You can see that postgresql is running correctly from the output.

We can only login to postgresql as ‘postgres’ user after the installation. Then we have to create other user and databases as we like from there to access it without using ‘postgres’ user.

To login as ‘postgres’ user, first set up a password for ‘postgres’ user using the following command:

$ sudo passwd postgres

Now login as ‘postgres’ user with the following command:

$ su - postgres

Once you’re logged in as ‘postgres’ user, run the following command to access the command line interface of PostgreSQL 10:

$ psql

You can see that, you’re using PostgreSQL 10.1 and the prompt where you can run other PostgreSQL commands.

So that’s how you install PostgreSQL 10 on Ubuntu 17.10 Artful Aardvark. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Installing pgAdmin 4 on Debian 10

pgAdmin is a graphical tool for administering PostgreSQL database servers like phpMyAdmin to MySQL/MariaDB database servers....
29/12/2020

PostgreSQL Arrays Tutorial

Variable-length one-dimensional or multi-dimensional arrays can be defined as a field of a table in PostgreSQL database....
28/12/2020

5 Best GUI Clients for PostgreSQL on Ubuntu

Written in C, PostgreSQL which is also known as Postgres is one of the most popular relational database management systems....
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024