How to stop PostgreSQL in linux?

by wilmer.lemke , in category: PHP Databases , 2 years ago

How to stop PostgreSQL in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by lindsey.homenick , 2 years 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.

by cortez.connelly , a year ago

@wilmer.lemke 

To stop PostgreSQL in Linux, you can follow these steps:

  1. Open a terminal window.
  2. Switch to the PostgreSQL system user by running the command: sudo su - postgres
  3. Stop the PostgreSQL service by executing the following command: pg_ctl -D /path/to/postgresql/data_directory stop Replace "/path/to/postgresql/data_directory" with the actual path to your PostgreSQL data directory. By default, it could be "/var/lib/postgresql//main".
  4. If prompted, enter the PostgreSQL system user's password.
  5. PostgreSQL should now be stopped.


Note: Depending on your Linux distribution and setup, the above steps might vary slightly.