patternsqlMinor
Where are PostgreSQL databases stored on my computer?
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:
And then I did the command:
Which supposedly created the database.
But where is this database? Where can I find it on my computer?
So I'm making a Postgres database on the postgres server, that I started up with this command:
sudo -u postgres psqlAnd 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
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.
show data_directorycommand 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_directoryContext
StackExchange Database Administrators Q#36811, answer score: 9
Revisions (0)
No revisions yet.