How to install PostgreSQL with pgAdmin on Ubuntu Linux
PostgreSQL is an object-relational database management system ( ORDBMS ). It is very popular and has a ton of advanced features.
pgAdmin is another great tool that can help out a lot.
Installing PostgreSQL on Ubuntu
Update repo:
sudo apt update
Install the packages:
sudo apt install postgresql postgresql-contrib
Optionally, edit the config file to allow connection remotely:
sudo vim /etc/postgresql/9.1/main/postgresql.conf
change this:
#listen_addresses = "localhost"
to this:
listen_addresses = "*"
Configure which networks should be able to connect to the database:
sudo vim /etc/postgresql/9.1/main/pg_hba.confhost all all 192.168.2.0/24 md5 host all all 192.168.3.0/24 md5 host all all 127.0.0.0/32 md5
Restart and enable the postgresql service:
sudo systemctl start postgresql
sudo systemctl enable postgresql
Connect using the CLI:
sudo -u postgres psql
Create a new user:
CREATE USER user1 WITH PASSWORD 'password';
Add permissions for this user:
ALTER USER user1 CREATEDB;
Create a new test database:
CREATE DATABASE test1;
Exit the CLI:
\q
Install pgAdmin on Ubuntu
Update repo:
sudo apt update
Install curl and cert stuff that we need:
sudo apt install curl ca-certificates
Install the repo:
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/pgadmin-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/pgadmin-archive-keyring.gpg] https://www.pgadmin.org/static/packages_pgadmin_org.$(lsb_release -cs).list stable" | sudo tee /etc/apt/sources.list.d/pgadmin.list
Update the repo again:
sudo apt update
Install the package:
sudo apt install pgadmin4
Configure pgAdmin here and add your database through the GUI:
http://localhost/pgadmin4 |