PostgreSQL is a free, open-source object-relational database management system (object-RDBMS), similar to MySQL, and is standards-compliant and extensible. It often is used as a back-end for web and mobile applications. PostgreSQL, or ‘Postgres’ as it is nicknamed, adopts the ANSI/ISO SQL standards together, with the revisions.
- These instructions are intended specifically for installing PostgreSQL on Fedora 23. For instructions on other operating systems, check out How to Install and Connect to PostgreSQL on Fedora 22, How to Install and Connect to PostgreSQL on CentOS 7, and How to Install and Connect to PostgreSQL on Ubuntu 14.04
- We’ll be logging into a Liquid Web Self Managed Fedora 23 server as root.
Step #1: Add the PostgreSQL 9.4 Repository
In this case we want to install PostgreSQL 9.4.4 directly from the Postgres repository. First, we’ll add the repo:
rpm -iUvh http://yum.postgresql.org/9.4/fedora/fedora-23-x86_64/pgdg-fedora94-9.4-4.noarch.rpm
Step #2: Install PostgreSQL
First, we’ll observe best practices by ensuring that the list of available packages is up to date:
dnf -y update
Then it’s a matter of running one command for installation:
dnf -y install postgresql94 postgresql94-server postgresql94-contrib postgresql94-libs --enablerepo=pgdg94
PostgreSQL now should be installed.
Step #3: Start PostgreSQL
Configure Postgres to start when the server boots:
systemctl enable postgresql-9.4
That should produce output similar to the following:
[root@host ~]# systemctl enable postgresql-9.4
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.4.service to /usr/lib/systemd/system/postgresql-9.4.service.
Initialize Postgres with the following command:
Which should result in:
Initializing database ... OK
Then start Postgres:
systemctl start postgresql-9.4
Step #4: Switch to the Default PostgreSQL User
As part of the installation, Postgres adds the system user “postgres” and is setup to use “ident” authentication. Roles internal to Postgres (which are similar to users) match with a system user account.
Let’s switch into that system user:
su - postgres
You’ll receive a command line similar to:
And then connect to the PostgreSQL terminal (in the postgres role):
To quit psql, type:
and to return to the previous user, type:
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.