How to Install PostgreSQL 11 on Ubuntu 16.04 | 18.04 Servers
The steps below show students and new users how to easily install PostgreSQL 11 on Ubuntu 16.04 and 18.04 servers easily from the command line terminal… If you haven’t installed PostgreSQL 11, continue below to get it installed…
PostgreSQL, a powerful open source object-relational database has seen a new release… version 11 and this brief tutorial is going to show students and new users how to easily install it on Ubuntu 16.04 | 18.04 and 18.10….
For those who don’t know PostgreSQL, or simple PostgreSQL, here’s a brief overview…
PostgreSQL is a general purpose and object-relational database management system, probably the most advanced open source database system…. you can also add custom functions using different programming languages such as C/C++, Java, etc…
It is used by major corporations and businesses looking for high performance database systems…
Most people will tell you a thing or two about MySQL and MariaDB… however, for professionals, PostgresSQL reigns..
To learn how to install PostgreSQL 11 Ubuntu, follow the steps below
Step 1: Add PostgresSQL Repository to Ubuntu
Adding PostgresSQL repository to Ubuntu is easy… all you have to run is run the commands below to add the repository key.,., the key is there to authenticate and validate pcakges from the repository….
Run the commands below to add the repository key and the repository…
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" > /etc/apt/sources.list.d/PostgreSQL.list'
When you’re done… continue below…
Step 2: Update and Install PostgreSQL
Now that the repository and key are added, run the commands below to update and install the latest PostgresSQL packages..
To install PostgreSQL 11, run the commands below
sudo apt update sudo apt-get install postgresql-11
That’s it!
After installing PostgreSQL, the commands below can be used to stop, start, enable and check its status
sudo systemctl stop postgresql.service sudo systemctl start postgresql.service sudo systemctl enable postgresql.service sudo systemctl status postgresql.service
This is what the status command shows
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor prese
Active: active (exited) since Wed 2018-10-31 11:58:09 CDT; 12s ago
Main PID: 7930 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4663)
CGroup: /system.slice/postgresql.service
Oct 31 11:58:09 ubuntu1804 systemd[1]: Starting PostgreSQL RDBMS...
Oct 31 11:58:09 ubuntu1804 systemd[1]: Started PostgreSQL RDBMS.
Step 3: Creating PostgreSQL Linux User Password…
After installing PostgreSQL, it’s a good idea to create / change the default PostgreSQL user password… Run the commands below to create / change the user password in the bash shell and not PostgreSQL interactive shell..
Set password for Linux user (postgres)
sudo passwd postgres
You should be prompted to create a new Linux password for postgres user..
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
After setting a new password, every time you want to access PostgreSQL interactive shell, you’ll be prompted to confirm the password you created after running the commands above…
Step 4: Accessing PostgreSQL
Now that PostgreSQL is installed, to access its interactive shell and manage databases… you need to log in as the postgres user… to do that run the commands below:
sudo su -l postgres
Then use the psql command in an interactive shell when you want to create and manage PostgreSQL databases.
psql
Set password for DB administrator (postgres)
su - postgres psql
On psql shell, run below command to change database admin password.
postgres=# \password
OR
postgres=# \password postgres
That’s it!!!
This is how to install PostgreSQL on Ubuntu and set the user and database admin passwords…
If you want to install PostgreSQL web client, like phpMyAdmin, run the commands below
sudo apt-get install pgadmin3
You may also like the post below:
I`d like to suggest to add:
to edit postgresql.conf and add: listen_addresses = ‘*’ (or specific addressess)
and edit pg_hba.conf and add a rule for for example local hosts: host all all 192.168.1.0/24 trust
To enable local hosts to administer a standalone instance fromout the local lan.
Superb howto, thanks !