Setting up postgres database
Postgres database is highly scalable and JSON storing capacity..
let start setting up on ubuntu 18
step 1:
sudo apt update
sudo apt install postgresql postgresql-contrib
Switching Over to the postgres Account:
sudo -i -u postgres
You can now access a Postgres prompt immediately by typing:
psql
to Exit
\q
step 2:
creating new database:
sudo -u postgres psql
createdb test_database
sudo -u postgres createdb test_database
its done!!
Step 3:
connecting to remote client:
check status and log details
tail /var/log/postgresql/postgresql-9.5-main.log
ping it via (tcp is enabled or not.)
telnet server_host_address 5432
add Config:
Get Anupam Maurya’s stories in your inbox
Join Medium for free to get updates from this writer.
vim /etc/postgresql/9.5/main/pg_hba.conf
host all all 192.168.1.0/24 md5
vim /etc/postgresql/9.5/main/postgresql.conf
enable firewall with tcp config:
firewall-cmd — get-active-zones
firewall-cmd — zone=public — add-port=5432/tcp — permanent
apt install firewalld
firewall-cmd — zone=public — add-port=5432/tcp — permanent
firewall-cmd — reload
netstat -nlt
sudo ufw allow 5432/tcp
to restart
service postgresql restart
/etc/init.d/postgresql restart
# Database administrative login by Unix domain socket
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 trust
host all all youserver_ip/32 trust
host all all 192.168.1.0 255.255.255.0 trust
host all all 192.168.1.0/24 trust
host all all 0.0.0.0/0 md5
host all all ::/0 md5
vim /etc/postgresql/9.5/main/postgresql.conf
listen_addresses = ‘*’
:wq
service postgresql restart
/etc/init.d/postgresql restart
you are done!! with it




