how to install postgres database on linux server

Published: 05 March 2022
on channel: DBA Cave
5,740
33

In this video I will show how to install postgres SQL database on linux server.


steps


---if you have internet on your server then

yum install -y https://download.postgresql.org/pub/r...


---install postgresql
yum install -y postgresql12


---install postgresql server package
yum install -y postgresql12-server postgresql12-devel postgresql12-libs postgresql12-contrib


---add posgres user
useradd postgres


---set password
passwd postgres


---make the suitable directory for database
mkdir /home/postgres/data


---give proper permission on data directory
chown postgres:postgres -R /home/postgres/data




---switch to posgres user
su - postgres


---set environment by edit bash_profile
vi .bash_profile


#PostgreSQL Server Environment Variable Settings.
LD_LIBRARY_PATH=/usr/pgsql-12/bin

export LD_LIBRARY_PATH
PATH=/usr/pgsql-12/bin:$PATH
export PATH
PGDATA=/home/postgres/data
export PGDATA
echo "PG Profile Loaded"
echo "DATA AREA is /home/postgres/data"
echo "PostgreSQL Version is 12"


---initialize database cluster
initdb


---start the server
pg_ctl start -l ~/pglog.txt


---if permission error then do it
chown postgres:postgres -R /var/run/postgresql/


---connect to database
psql


---check the preinstalled database
\l


---create a test database
create database testdb;


---change connected to new testdb database
\c testdb


---exit from database connection
\q


On this page of the site you can watch the video online how to install postgres database on linux server with a duration of hours minute second in good quality, which was uploaded by the user DBA Cave 05 March 2022, share the link with friends and acquaintances, this video has already been watched 5,740 times on youtube and it was liked by 33 viewers. Enjoy your viewing!