Skip to content

Setting Up PostgreSQL

Anton Shcherbyna edited this page Feb 3, 2018 · 1 revision

PostgreSQL can be installed using YUM.

Install PostgreSQL

Get list available packages:

yum list postgresql*

Install PostgreSQL 9.6 server:

yum install postgresql96-server

Post-installation commands

After installing the packages, a database needs to be initialized and configured. In the commands below, the value of will vary depending on the version of PostgreSQL used. For PostgreSQL version 9.0 and above, the includes the major.minor version of PostgreSQL, e.g., postgresql-9.4

Data Directory

The PostgreSQL data directory contains all of the data files for the database. The variable PGDATA is used to reference this directory.

The default data directory is:

/var/lib/pgsql/<name>/data

For example:

/var/lib/pgsql/9.6/data
Initialize

The command (only needed once) is to initialize the database in PGDATA.

/usr/pgsql-9.6/bin/postgresql96-setup initdb
```

##### Startup
If you want PostgreSQL to start automatically when the OS starts, do the following:
````javascript
 systemctl enable postgresql-9.6.service
Control service

To control the database service, use:

 systemctl enable postgresql-9.6.service
 systemctl start postgresql-9.6.service
Removing

To remove everything:

yum erase postgresql96*

Clone this wiki locally