How To Install and Connect to PostgreSQL on Fedora 23

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.

Pre-Flight Check

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:

/usr/pgsql-9.4/bin/postgresql94-setup initdb

Which should result in:

/usr/pgsql-9.4/bin/postgresql94-setup initdb
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:

-bash-4.3$

And then connect to the PostgreSQL terminal (in the postgres role):

psql

To quit psql, type:

\q

and to return to the previous user, type:
exit
 

Be Sociable, Share!
Here's $75, Launch a New VPS Today. Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7 Heroic Support.