Город МОСКОВСКИЙ
00:16:47

how to install postgres database on linux server

Аватар
PHP школа
Просмотры:
25
Дата загрузки:
01.12.2023 02:42
Длительность:
00:16:47
Категория:
Лайфстайл

Описание

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/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm


---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

Рекомендуемые видео