Install PgAdmin4 on Ubuntu

PgAdmin is a popular open source management and development tool which is released under PostgreSQL/Artistic license. Different types of database operations can be done easily from the browser by using this software. This software can be used on most popular operating systems. Currently, pgAdmin 4 is released and it is developed using Python and JQuery. Many improvements are done in pgAdmin 4 compared to pgAdmin 3. Anyone can download the source or binary file of this software based on a particular operating system for installation. The user will be required to have some technical knowledge to install pgAdmin by compiling source file. So that installation process is for advance users only. Installing pgAdmin from binary file is the best way for the novice user. How you can install and use pgAdmin on Ubuntu from binary files are shown in this tutorial.

See below video tutorial on PGAdmin4 Installaiton on Ubuntu:

PgAdmin 4 Installation Steps

1. Update the system

Before starting the installation process, you have to update the system by executing the following command.

$ sudo apt-get update

2. Install required packages

Three packages require to install before downloading pgAdmin which are python, pip and virtualenv. Run the following command to install these packages.

$ sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev
virtualenv python-pip libpq-dev python-dev

When the following prompt appears then press ‘y’ to complete the installation process of the required packages.

3. Create virtual environment

Run the following commands to create a new folder named pgAdmin4 in the current location, go to the newly created folder and create the virtual environment.

$ mkdir pgAdmin4
$ cd pgAdmin4
$ virtualenv pgAdmin4

4. Activate virtual environment

Go to pgAdmin4 folder under pgAdmin4 and run the following commands to activate the virtual environment.

$ cd pgAdmin4
$ source bin/activate

5. Download pgAdmin 4

Run the following command to download the latest version of pgAdmin 4.

$ wget

After completing the download of pgAdmin, the console will be look like the following image.

6. Install pgAdmin 4

Run the following command to complete the installation process of pgAdmin 4.

$ pip install pgadmin4-2.1-py2.py3-none-any.whl

After installation, the following screen will appear.

7. Configure and run pgAdmin 4

After completing the installation steps, you have to create a configuration file to run this software. Create a new file named in lib/python2.7/site-packages/pgadmin4/ folder using nano editor.

$ nano lib/python2.7/site-packages/pgadmin4/

Add the following content in

import os
DATA_DIR = os.path.realpath(os.path.expanduser(u’~/.pgadmin/’))
LOG_FILE = os.path.join(DATA_DIR, ‘pgadmin4.log’)
SQLITE_PATH = os.path.join(DATA_DIR, ‘pgadmin4.db’)
SESSION_DB_PATH = os.path.join(DATA_DIR, ‘sessions’)
STORAGE_DIR = os.path.join(DATA_DIR, ‘storage’)

Now, use the following command to run pgAdmin.

$ python lib/python2.7/site-packages/pgadmin4/

***Note: If any flask-htmlmin module error appears then run the following commands to install the module and then run the server.

$ pip install flask-htmlmin
$ python lib/python2.7/site-packages/pgadmin4/

The following message will appear if pgAdmin can run successfully.

Now, access http://localhost:5050 from any browser. If all the steps are completed properly then the browser will display the following page.

Using pgAdmin 4

Before using pgAdmin, you need to confirm that the latest version of PostgreSQL is installed on your operating system. Run the following command to install postgres package for PostgreSQL and contrib package for taking additional functionalities related to PostgreSQL.

$ sudo aptGET install postgresql postgresqlcontrib

Type ‘y’ when the following message appear in the terminal to complete the installation process.

Next, you have to create the username and password for PostgreSQL database. Type the following command in the terminal to add login credentials for the user, postgres.

$ sudo u postgres psql postgres

Setup the password for the username, ‘postgres’. It will ask to type the password two times for confirmation.

# password postgres

If you want to quit from the interactive session of postgres then type ‘q’.

 PostgreSQL is now ready to use. Go to the pgAdmin browser and click on the ‘Add New Server’ option.

There are four tabs in ‘Creat-Server’ dialog box. In General tab, type the name for the new server. Here, ‘TestDB’ is set as server name. Setting background and foreground colors are optional. Make Connect now option checked.

Click on the Connection tab and type Host name/address. Here, localhost is used as host name. By default port is 5432 and keep it unchanged now. postgres is set as maintenance database by default. Default username of this database is also set as postgres which is created earlier. Type the password for postgres user that you have created before. Make Save password option on. The other two tabs of this dialog box, SSL and Advanced are used for advanced setting which are omitted in this tutorial. Click on the Save button to create the TestDB server.

When you expand TestDB server, the following screen will appear. Three sections will appear in the left side of the browser. These are Databases, Login/Group Roles and Tablespaces.

There is only one database exists named postgres in Databases part. If you want then you can  create new database from this section and after creation the database will be added in this section.

Two login information are shown in Login/Group Roles section. These are pg_signal_backend which is created at the time of installation and postgres which is created later after installation. You can also create new user and role from this section.

Third section is Tablespaces which are used to define the location of the data files containing database objects such as tables, indexes etc. By default, two tablespaces named  pg_default and pg_global are created here. If you want you can also create your own tablespace from this section.

The right plan of the browser shows the overall server status and activities which are the up and downtime of the server, the numbers of database transaction per second, tuples in, tuples out, Block I/O and server activity information. There are four parts in server activity section to get more detail information related to server current activities. These are user session,lock information, prepared statements and configuration.

So, you can do various types of PostgreSQL database operations and monitor the current database avtivities easily by using pgAdmin tool. To advance to the next level see the tutorial below which will go into more details of the usage of PGAdmin4:

PGAdmin4 Tutorial Beginners

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

How to install Qt 5.9.1 (Qt Creator 4.3.1 included) on Ubuntu 17.04

Qt 5.9.1 the most recent release, is a cross-platform application framework that is widely used for developing apps with...

How to change from DHCP to Static IP Address in Ubuntu 17.04

Before we proceed with how to change from DHCP to Static IP Address in Ubuntu 17.04, lets review what a DHCP is and why...

How To Install Prometheus on Ubuntu 18.04

Overview Prometheus is an excellent open-source monitoring system which allows us to collect metrics from our applications...
Bài Viết

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

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh

Mua proxy Onet uy tín tại

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?