...
Through the pg_ctl tool that comes with PostgreSQL, it is easy to start and stop a PostgreSQL database. In a default installation the pg_ctl tool is located in
Code Block |
---|
../application_server/postgres_db/bin/ |
When you have used the EnterpriseDB (EDB) installer then all of PostgreSQL (binary and database cluster) is installed in the following directory:
OSX
Code Block |
---|
/Library/PostgreSQL/9.0/
|
Windows
Code Block |
---|
C:\Program Files\PostgreSQL\9.0\ |
Linux
Code Block |
---|
/opt/PostgreSQL/9.0/
|
Where the subdirectory bin holds the commandline tools and other binaries and the subdirectory data holds the database cluster. Also PostgreSQL will be running by the system user postgres and the data directory is only accesible by that user. All this is for security.
On linux however you can also use ready made packages specially made for the Linux distribution and have their own places of storing the various parts of PostgreSQL.
Starting PostgreSQL
Using the bundled PostgreSQL:
Code Block |
---|
postgres_db\bin\pg_ctl start -D database -l postgres_db\postgres_log.txt
|
When using the EDB installed version of PostgreSQL then the command is the following:
Code Block |
---|
sudo -u postgres /Library/PostgreSQL/9.0/bin/pg_ctl start -D /Library/PostgreSQL/9.0/data/ |
The EDB installed version already writes logs in the data/pg_log/ directory so no need to add the -l argument.
Stopping PostgreSQL
Using the bundled PostgreSQL:
Code Block |
---|
postgres_db\bin\pg_ctl stop -D database |
The commands above assume execution from the ../application_server/ directory. When executing from a different location, make sure to update the paths to the database (-D database) and the logfile (-l postgres_db\postgres_log.txt)When using the EDB installed version of PostgreSQL then the command is the following:
Code Block |
---|
sudo -u postgres /Library/PostgreSQL/9.0/bin/pg_ctl stop -D /Library/PostgreSQL/9.0/data/
|
You need to provide the location of the database cluster because you can have multiple instances of PostgreSQL running with different data directories.
...