Как остановить postgresql в linux
Перейти к содержимому

Как остановить postgresql в linux

  • автор:

TablePlus

In this post, we are going to figure out how to start, stop, and restart a PostgreSQL server on macOS, Linux, and Windows.

1. On macOS

If you installed PostgreSQL via Homebrew:

  • To start manually:
  • To stop manually:
  • To start PostgreSQL server now and relaunch at login:
  • And stop PostgreSQL:

If you want a hassle-free way to manage the local PostgreSQL database servers, use DBngin. It’s just one click to start, another click to turn off. No dependencies, no command line required, multiple drivers, multiple versions and multiple ports. And it’s free.

DBngin local server

2. On Windows

First, you need to find the PostgreSQL database directory, it can be something like C:\Program Files\PostgreSQL\10.4\data . Then open Command Prompt and execute this command:

  • To stop the server
  • To restart the server:
  • Open Run Window by Winkey + R
  • Type services.msc
  • Search Postgres service based on version installed.
  • Click stop, start or restart the service option.

3. On Linux

Update and install PostgreSQL 10.4

By default, the postgres user has no password and can hence only connect if ran by the postgres system user. The following command will assign it:

  • Start the PostgreSQL server
  • Stop the PostgreSQL server:

Need a good GUI tool for PostgreSQL on MacOS and Windows? TablePlus is a modern, native tool with an elegant GUI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.

Stopping a postgresql instance

For the sake of educational purposes I have two identical instances of postgresql running on my machine.

I can easily stop the service of the instance that is running on port 5432 like this :

What I like to know is that how I can stop the other instance (it is running on port 5433)

Beatles1692's user avatar

4 Answers 4

pg_ctl is the postreSQL way to stop postgreSQL (in Ubuntu and Debian we should use pg_ctlcluster which is a wrapper for pg_ctl ). The example in that link uses option `-p 5433″.

As suggested by naoko in the comments below, use pg_lsclusters to list clusters.

Another way is to give a kill signal to the process running postgresqld. To stop both at once, killall postgresqld might work.

Finally as suggested in the comment by psyCHOder, pgAdmin can also stop the server, but of course that means installing that package.

How to start stop PostgreSQL on Ubuntu

This article covers how to start, stop and restart PostgreSQL on Ubuntu. This is PostgreSQL DBA routine task.
We are going to cover stop, start and restart using service and systemctl commands. But, not covering to kill the PostgreSQL process from Linux shell.

Stop Start and Restart PostgreSQL using service:

Examples for How to start stop PostgreSQL on Ubuntu:

1. To know the status of PostgreSQL Server on Ubuntu:

2. To stop PostgreSQL on Ubunut by using service command:

To know the status of PostgreSQL Server on Ubuntu

3. To start PostgreSQL on Ubunut by using service command:

4. To restart PostgreSQL on Ubunut by using service command:

Method2: To start stop PostgreSQL on Ubuntu using systemctl:
Following commands are used to start stop PostgreSQL on Ubuntu using systemctl:

1. Start the PostgreSQL Stop on Ubunut:

2. Start the PostgreSQL Server on Ubunut:

3. Start the PostgreSQL Server on Ubunut:

For video tutorial for same “How to start stop PostgreSQL on Ubuntu”, watch below video.

Как остановить postgresql в linux

PostgreSQL is a widely used relational database because of its basic to advanced features. One of the notable features of Postgres is that it is compatible with various operating systems, such as Windows, Linux, and MacOS. It assists users in storing, managing, and retrieving large amounts of data efficiently. To get the maximum of Postgres features, it is necessary to learn how to start or stop the Postgres server on ubuntu.

This post is going to present a step-by-step guide on how to start or stop the PostgreSQL server on the Ubuntu operating system.

How to Start or Stop PostgreSQL Server on Ubuntu?

In Ubuntu, the Postgres server can be started or stopped using various methods. In this article a couple of well-known methods will be discussed to start or restart the Postgres server on Linux (Ubuntu):

  • Method 1: Using the “systemctl” Command
  • Method 2: Using the “/etc/init.d/postgresql” which is the script that systemctl calls.

Method 1: Start and Stop Postgres Server Using the “systemctl” Command

Here are the steps to start or stop the Postgres server on ubuntu using the “systemctl” command:

Step 1: Review the Postgres Status

Open the terminal and execute the following “sudo” command to review the current status of the Postgres server:

img

The above snippet shows that the Postgres server is currently deactivated.

Step 2: Start the Postgres Server

Use the below-given “sudo” command with the “start” option to begin the Postgres server:

img

The output illustrates that the Postgres server has been initiated successfully.

Step 3: Verify the Postgres Status

Use the below-given “sudo” command along with the “status” option to verify the Postgres status:

img

The output confirms that the Postgres Server has been activated successfully.

Step 4: Stop the Postgres Server

Type the “systemctl” command followed by the “stop” option to halt the Postgres server:

img

The output shows that the Postgres server has been stopped successfully.

Step 5: Confirm Postgres Status

Type the “systemctl” command followed by the “status” option to confirm the Postgres status:

img

The output proves that the Postgres server has been deactivated successfully.

Method 2: Start and Stop Postgres Server Using “/etc/init.d/postgresql”

To start or stop a Postgres server on Ubuntu, follow the below-given instructions:

Step 1: Review the Postgres Status

Open the terminal and execute the following command to review the current status of the Postgres server:

img

The above snippet states that the Postgres server is not active yet.

Step 2: Start the Postgres Server

Use the “/etc/init.d/postgresql” command with the start option to initiate the Postgres server:

img

The output shows that the Postgres server has been started successfully.

Step 3: Verify the Postgres Status

Use the “/etc/init.d/postgresql” command with the “status” option to verify the Postgres status:

img

The output demonstrates that the Postgres Server has been activated/started successfully.

Step 4: Stop the Postgres Server

Type the “/etc/init.d/postgresql” command followed by the “stop” option to halt the Postgres server:

img

The output shows that the Postgres server has been stopped successfully.

Step 5: Confirm Postgres Status

Type the “/etc/init.d/postgresql” command followed by the “status” option to confirm the Postgres status:

img

The output proves that the Postgres server has been stopped successfully.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *