Tutorial ini menunjukkan cara menginstal pgAdmin 4 di Ubuntu 20.04/18.04/16.04. pgAdmin adalah alat administrasi dan pengembangan PostgreSQL open-source, pgAdmin pada dasarnya digunakan untuk mengelola server database PostgreSQL.
Anda harus memiliki server PostgreSQL di Sistem/VM Lokal atau jarak jauh. Jika Anda tidak memilikinya, lihat dokumen di bawah ini dan instal PostgreSQL. Untuk tutorial ini, saya telah menginstal server PostgreSQL dan alat pgAdmin pada sistem Ubuntu yang sama.
Cara Menginstal PostgreSQL 12 di Ubuntu 20.04/18.04/16.04
Langkah Menginstal pgAdmin4 di Ubuntu
Langkah 1:Tambahkan repositori APT PostgreSQL
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
Contoh Keluaran:
root@PostgreSQL:~# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). OK root@PostgreSQL:~# sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update' Hit:1 http://us.archive.ubuntu.com/ubuntu groovy InRelease Hit:2 http://security.ubuntu.com/ubuntu groovy-security InRelease Hit:3 http://us.archive.ubuntu.com/ubuntu groovy-updates InRelease Hit:4 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/groovy pgadmin4 InRelease Hit:5 http://us.archive.ubuntu.com/ubuntu groovy-backports InRelease Reading package lists... Done Building dependency tree Reading state information... Done 206 packages can be upgraded. Run 'apt list --upgradable' to see them. root@PostgreSQL:~#
Langkah 2:Instal pgAdmin4 di Ubuntu
sudo apt install pgadmin4
Contoh Keluaran:
root@PostgreSQL:~# sudo apt install pgadmin4 Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: virtualbox-guest-utils Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: libapache2-mod-wsgi-py3 pgadmin4-desktop pgadmin4-server pgadmin4-web The following NEW packages will be installed: libapache2-mod-wsgi-py3 pgadmin4 pgadmin4-desktop pgadmin4-server pgadmin4-web 0 upgraded, 5 newly installed, 0 to remove and 206 not upgraded. Need to get 79.7 MB/161 MB of archives. After this operation, 300 kB of additional disk space will be used. Do you want to continue? [Y/n] Y Get:1 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/groovy pgadmin4/main amd64 pgadmin4-desktop amd64 5.2 [79.7 MB] Get:2 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/groovy pgadmin4/main all pgadmin4-web all 5.2 [2,640 B] Get:3 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/groovy pgadmin4/main all pgadmin4 all 5.2 [840 B] Fetched 69.0 MB in 59s (1,178 kB/s) Selecting previously unselected package libapache2-mod-wsgi-py3. (Reading database ... 195104 files and directories currently installed.) Preparing to unpack .../libapache2-mod-wsgi-py3_4.7.1-2_amd64.deb ... Unpacking libapache2-mod-wsgi-py3 (4.7.1-2) ... Selecting previously unselected package pgadmin4-server. Preparing to unpack .../pgadmin4-server_5.2_amd64.deb ... Unpacking pgadmin4-server (5.2) ... Selecting previously unselected package pgadmin4-desktop. Preparing to unpack .../pgadmin4-desktop_5.2_amd64.deb ... Unpacking pgadmin4-desktop (5.2) ... Selecting previously unselected package pgadmin4-web. Preparing to unpack .../pgadmin4-web_5.2_all.deb ... Unpacking pgadmin4-web (5.2) ... Selecting previously unselected package pgadmin4. Preparing to unpack .../archives/pgadmin4_5.2_all.deb ... Unpacking pgadmin4 (5.2) ... Setting up pgadmin4-server (5.2) ... Setting up libapache2-mod-wsgi-py3 (4.7.1-2) ... apache2_invoke: Enable module wsgi Setting up pgadmin4-desktop (5.2) ... Setting up pgadmin4-web (5.2) ... Setting up pgadmin4 (5.2) ... Processing triggers for mime-support (3.64ubuntu1) ... Processing triggers for hicolor-icon-theme (0.17-2) ... Processing triggers for gnome-menus (3.36.0-1ubuntu1) ... Processing triggers for desktop-file-utils (0.24-1ubuntu4) ... root@PostgreSQL:~#
Langkah 3:Konfigurasikan kredensial pgAdmin4
sudo /usr/pgadmin4/bin/setup-web.sh
Ganti ID Email [email protected] dan konfigurasikan kata sandi Anda yang kuat.
Setelah instalasi, layanan Apache akan dimulai
$ systemctl status apache2
Contoh Keluaran:
root@PostgreSQL:~# systemctl status apache2 ● apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor pres> Active: active (running) since Sun 2021-05-16 12:28:13 EDT; 4min 37s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 25828 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/> Main PID: 25832 (apache2) Tasks: 34 (limit: 4648) Memory: 33.9M CGroup: /system.slice/apache2.service ├─25832 /usr/sbin/apache2 -k start ├─25833 /usr/sbin/apache2 -k start ├─25834 /usr/sbin/apache2 -k start ├─25835 /usr/sbin/apache2 -k start ├─25836 /usr/sbin/apache2 -k start ├─25837 /usr/sbin/apache2 -k start └─25838 /usr/sbin/apache2 -k start May 16 12:28:12 PostgreSQL systemd[1]: Starting The Apache HTTP Server... May 16 12:28:13 PostgreSQL apachectl[25831]: AH00558: apache2: Could not relia> May 16 12:28:13 PostgreSQL systemd[1]: Started The Apache HTTP Server. root@PostgreSQL:~#
Langkah 4:Konfigurasi firewall di Ubuntu (Opsional)
sudo ufw allow http sudo ufw allow https
Contoh Keluaran:
root@PostgreSQL:~# sudo ufw allow http Rules updated Rules updated (v6) root@PostgreSQL:~# sudo ufw allow https Rules updated Rules updated (v6) root@PostgreSQL:~#
Langkah 5:Akses pgadmin4 di browser web
http://[ServerIP_or_domain]/pgadmin4
Login dengan Kredensial yang telah kita buat di langkah 3
Setelah Anda login, Anda akan mendapatkan layar di bawah ini.
Langkah 6:Tambahkan server PostgreSQL untuk dikelola dengan pgAdmin
Klik “Tambah Server Baru” (Anda dapat menambahkan server PostgreSQL lokal atau jarak jauh)
Di bawah “Umum ”, Beri nama server PostgreSQL dengan deskripsi
Sekarang, klik pada “Koneksi tab”, berikan detail server seperti IP/host PostgreSQL, pengguna basis data, dan kata sandi
Sekarang simpan. Jika semua konfigurasi sudah benar, Anda akan dapat melihat server PostgreSQL di sisi kiri.
Di akhir artikel, kita telah melihat cara menginstal pgAdmin 4 di Ubuntu 20.04/18.04/16.0 dan menjelajahi lebih lanjut di UI web pgAdmin.