How to stop PostgreSQL in linux?

by wilmer.lemke , in category: PHP Databases , 9 months ago

How to stop PostgreSQL in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by lindsey.homenick , 3 months ago

@wilmer.lemke 

To stop a PostgreSQL server on Linux, you can use the following steps:

  1. Connect to the server using the psql command-line interface:psql -U postgres
  2. Use the pg_ctl command to stop the server:SELECT pg_ctl('stop');


Alternatively, you can use the following command to stop the server from the command line:

1
pg_ctl stop -D /path/to/data/directory


This will stop the server and shut it down. If you want to stop the server and leave it running in the background, you can use the -m option:

1
pg_ctl stop -D /path/to/data/directory -m fast


This will stop the server and leave it running in the background, but it will not accept new connections or process any new transactions.


If you are using a version of PostgreSQL that is older than 9.3, you can use the following command to stop the server:

1
pg_ctl stop -D /path/to/data/directory -m fast


This will stop the server and leave it running in the background, but it will not accept new connections or process any new transactions.


I hope this helps! Let me know if you have any questions.