Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart PostgreSQL in Ubuntu 18.04

Tags:

postgresql

How to restart PostgreSQL via ssh console?

When i search this thing on SO I only find: postgres, ubuntu how to restart service on startup? get stuck on clustering after instance reboot

like image 347
Ismail Yavuz Avatar asked Oct 02 '18 14:10

Ismail Yavuz


People also ask

How do I start PostgreSQL in terminal?

Getting a PostgreSQL command prompt You can get a command shell in Windows by running cmd.exe. The CSEP544 shell launcher script will also open a shell for you. Type psql -U postgres at the prompt, and hit Enter. Here, postgres represents the username of the database superuser.


2 Answers

sudo service postgresql restart 
like image 77
Ismail Yavuz Avatar answered Sep 25 '22 15:09

Ismail Yavuz


systemctl restart postgresql@<postgres_version>-<cluster_name>.service 

By default cluster_name = 'main', run this command to list all the clusters you have :

ls /var/lib/postgresql/ 

if you want to know whether the postgresql is running try this command :

systemctl status postgresql@<postgres_version>-<cluster_version>.service 
like image 43
aziz aziz Avatar answered Sep 25 '22 15:09

aziz aziz