HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Where are PostgreSQL databases stored on my computer?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlstoreddatabasesarewherecomputer

Problem

So this might be a stupid question, but I'm really new to this.
So I'm making a Postgres database on the postgres server, that I started up with this command:

sudo -u postgres psql


And then I did the command:

CREATE DATABASE database;


Which supposedly created the database.
But where is this database? Where can I find it on my computer?

Solution

Where exactly your data is stored depends on how you installed and configured PostgreSQL. Running the

show data_directory


command as the postgres user (from inside the psql tool or another client) will tell you where it is though. For example, if you installed it from the debian or ubuntu repositories you would probably find your data files are somewhere like /var/lib/postgresql/9.2/main.

There probably isn't anything terribly interesting in there though. Sometimes there are a few configuration files like pg_hba.conf (the windows version puts them there at least) but if you're on debian you'll find those under /etc/postgresql/.

If you're expecting your database to be a single file that you can move around between systems, etc, you're probably better off using a simpler embedded database like sqlite.

Code Snippets

show data_directory

Context

StackExchange Database Administrators Q#36811, answer score: 9

Revisions (0)

No revisions yet.