Friday, April 4, 2008

how to stop postgres on ubuntu Linux

After been installed, postgres started automatically.

you can look on command line used to start it


$ ps -ef | grep post
postgres 12089 1 0 10:38 ?
00:00:00 /usr/lib/postgresql/8.3/bin/postgres
-D /var/lib/postgresql/8.3/main
-c config_file=/etc/postgresql/8.3/main/postgresql.conf
...other postgres processes...


it can not be stopped by not owner or sudo:

~$ sudo /usr/lib/postgresql/8.3/bin/pg_ctl stop
/var/lib/postgresql/8.3/main/
[sudo] password for rtg:
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
$ /etc/init.d/postgresql-8.3 stop
* Stopping PostgreSQL 8.3 database server * Error: You must run this program as the cluster owner (postgres)
[fail]


To stop, set postgres password first.

It is unknown at the beginning.

rtg@deeeb:~$ su postgres
Password:
su: Authentication failure
Sorry.


to set it:
sudo passwd postgres

set password;
then login ,
su postres
put your password you set before

and stop it,OK:

$ /usr/lib/postgresql/8.3/bin/pg_ctl stop
-D /var/lib/postgresql/8.3/main/
waiting for server to shut down.... done
server stopped

No comments: