DEV Community

Aimé Bangirahe
Aimé Bangirahe

Posted on

Installing PostgreSQL for Linux

This task installs PostgreSQL for Linux Servers

Procedure :

  • Log in as root user:
sudo su
Enter fullscreen mode Exit fullscreen mode
  • Download the PostgreSQL source:
wget https://ftp.postgresql.org/pub/source/v9.5.13/postgresql-9.5.13.tar.gz
Enter fullscreen mode Exit fullscreen mode
  • Install PostgreSQL using the following commands:
tar -zxvf postgresql-9.5.13.tar.gz
cd postgresql-9.5.13/
yum -y install readline-devel
./configure --prefix=/usr/local/postgresql
make
make install
Enter fullscreen mode Exit fullscreen mode
  • Create the postgres user and change the owner of the postgres directory :
useradd postgres
chown -R postgres:postgres /usr/local/postgresql/
Enter fullscreen mode Exit fullscreen mode
  • Log in as the postgres user:
su postgres
Enter fullscreen mode Exit fullscreen mode
  • Configure the system path for postgres:
vi ~/.bashrc
PGHOME=/usr/local/postgresql
export PGHOME
PGDATA=/usr/local/postgresql/data
export PGDATA
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PGHOME/bin
export PATH
Enter fullscreen mode Exit fullscreen mode
  • Reload the configuration using the source command:
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode
  • Initialize the PostgreSQL database:
initdb
Enter fullscreen mode Exit fullscreen mode
  • Configure the database. Open postgresql.conf in vi:
vi /usr/local/postgresql/data/postgresql.conf
Enter fullscreen mode Exit fullscreen mode

Replace:

#listen_address='localhost' 
#port = 5432 
Enter fullscreen mode Exit fullscreen mode

about :

listen_address='*' 
port = 5432
Enter fullscreen mode Exit fullscreen mode
  • Open the pg_hba.conf file in vi:
vi /usr/local/postgresql/data/pg_hba.conf
Enter fullscreen mode Exit fullscreen mode

Add the following line to the file:

host all all 0.0.0.0/0 trust
Enter fullscreen mode Exit fullscreen mode
  • Restart postgresql:
pg_ctl -D /usr/local/postgresql/data -l logfile restart
Enter fullscreen mode Exit fullscreen mode
  • Change the password for the postgres user in the PostgreSQL database: If the postgresql service is not started, run the following commands:
Add /usr/local/pgsql/bin/
Enter fullscreen mode Exit fullscreen mode

to the file: Run the following command:

psql
ALTER USER postgres WITH PASSWORD 'mot_de_passe';
\q

su postgres
vi ~/.bashrc

export PATH=/usr/local/cuda-8.0/bin:$PATH:/usr/local/pgsql/bin/

source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode
  • Create the database schema in PostgreSQL. Run the following command on the psql console:
create database edge with owner postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
Enter fullscreen mode Exit fullscreen mode

In the database, create the following tables:

CREATE TABLE vi_titulaire_inspectionresult(id text, info jsonb); 
CREATE TABLE vi_titulaire_notification(id text, info jsonb); 
CREATE TABLE vi_titulaire_defectsummary(id text, info jsonb); 
CREATE TABLE vi_titulaire_uploaddataset(id text, info jsonb); 
CREATE TABLE vi_titulaire_syncprocess(id text, info jsonb); 
CREATE TABLE vi_titulaire_model(id text, info jsonb); 
CREATE TABLE vi_titulaire_datagroup(id text, info jsonb);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)