Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i want to hand in a course work for marking but i have no idea what files represent the database. Question: Where can i find the postgres sql database on my hard disk? Thanks.

share|improve this question
add comment

migrated from stackoverflow.com Mar 6 '11 at 13:11

This question came from our site for professional and enthusiast programmers.

4 Answers

up vote 10 down vote accepted

You should use pg_dump to export the database to SQL. Giving the raw files won't work if they are running a different version, 64bit instead of 32bit or something else in the environment.

You can easily export it using pgadmin3

share|improve this answer
add comment

Checkout the startup parameter -D for the Postgres service. It defines where the data directory is located.

Edit:
To hand in your homework, you'd better export the database using pg_dump as WoLpH suggested. The actual files in the data directory are binary files and I bet your teacher want's to have SQL scripts

share|improve this answer
add comment

The database files are in what is called the "data" directory. Depending on your environment there are a few ways to tell - here is one that should work everywhere:

psql -d database_name_here -c "show data_directory"

And if you're turning this in for some school work you should:

pg_dump -d database_name_here

share|improve this answer
add comment

If installed by apt-get or similar package manager, most likely in

/usr/local/pgsql/data
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.