Sunday, July 5, 2020

Check if PostgreSQL is running on UBUNTU - Start/Stop

There are commands within ubuntu to check if your postgresql is running or not. Based on its status, you can either start or stop. 

Check if postgresql is running, run following cmd
root@DESKTOP:~# sudo /etc/init.d/postgresql start
10/main (port 5432): down
The output of the above cmd shows the postgresql version and port and status. So the status down means that the server is not running, lets start the server, use following command

root@DESKTOP:~# sudo /etc/init.d/postgresql start
 * Starting PostgreSQL 10 database server
So now you can connect to your postgresql. Inorder to stop the server use following command
root@DESKTOX-QMQVNCE:~# sudo /etc/init.d/postgresql stop
 * Stopping PostgreSQL 10 database server