How to restart Postgresql
PostgresqlLinux MintPostgresql Problem Overview
I have PostgreSQL 9.3
and 9.4
installed on my Linux Mint machine.
How can I restart PostgreSQL 9.4?
A method to restart both versions together is also fine.
Postgresql Solutions
Solution 1 - Postgresql
Try this as root (maybe you can use sudo
or su
):
/etc/init.d/postgresql restart
Without any argument the script also gives you a hint on how to restart a specific version
[Uqbar@Feynman ~] /etc/init.d/postgresql
Usage: /etc/init.d/postgresql {start|stop|restart|reload|force-reload|status} [version ...]
Similarly, in case you have it, you can also use the service
tool:
[Uqbar@Feynman ~] service postgresql
Usage: /etc/init.d/postgresql {start|stop|restart|reload|force reload|status} [version ...]
Please, pay attention to the optional [version ...]
trailing argument.
That's meant to allow you, the user, to act on a specific version, in case you were running multiple ones. So you can restart version X while keeping version Y and Z untouched and running.
Finally, in case you are running systemd, then you can use systemctl
like this:
[Uqbar@Feynman ~] systemctl status postgresql
ā postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2017-11-14 12:33:35 CET; 7min ago
...
You can replace status
with stop
, start
or restart
as well as other actions. Please refer to the documentation for full details.
In order to operate on multiple concurrent versions, the syntax is slightly different. For example to stop v12
and reload v13
you can run:
systemctl stop postgresql-12.service
systemctl reload postgresql-13.service
Thanks to @Jojo for pointing me to this very one.
Finally Keep in mind that root
permissions may be needed for non-informative tasks as in the other cases seen earlier.
Solution 2 - Postgresql
You can also restart postgresql by using this command, should work on both the versions:
sudo service postgresql restart
Solution 3 - Postgresql
On Windows :
1-Open Run Window by Winkey + R
2-Type services.msc
3-Search Postgres service based on version installed.
4-Click stop, start or restart the service option.
On Linux :
sudo systemctl restart postgresql
also instead of "restart" you can replace : stop or status.
Solution 4 - Postgresql
This should work:
sudo systemctl stop postgresql
sudo systemctl start postgresql
Solution 5 - Postgresql
The right way to restart postgres server is to use
> pg_ctl restart -D /home/postgres/postgresdbdata/
pg_ctl is usually found in location usr/local/pgsql/bin/pg_ctl if u dont have it added to your path.
Documentation can be found here https://www.postgresql.org/docs/13/app-pg-ctl.html This has more details on Start,Stop,Restart,etc of the postgres server.
Solution 6 - Postgresql
You can firstly check for the postgress process running
ps -ef | grep post
You might need to use (post|pg) on the grep side, to discover the process for the Postgres service running on your machine, it might depend on your OS.
And you can just kill the child process since most of this process should restart automatically.
sudo kill $pid_of_the_child_process
Solution 7 - Postgresql
macOS:
- On the top left of the MacOS menu bar you have the Postgres Icon
- Click on it this opens a drop down menu
- Click on Stop -> than click on start