Database File Structure Location
Cerebro Support avatar
Written by Cerebro Support
Updated over a week ago

PostgreSQL database is a directory on the disk drive which contains a certain type of file structure. Configuration files are located in the top level directory. They allow you to configure various PostgreSQL parameters.

In case you already have PostgreSQL service installed, you might need to determine the location of its database. To do this, you need to know command line parameters it was launched with.


Open the Services tool. Click the PostgreSQL service in the list, right-click, and then click Properties from the context menu.

In the displayed window in the Path to executable field you can see (select and copy if needed) the service start command with all parameters.


When the PostgreSQL service is running at the background, run the following command in console:

ps afx | grep postgres

In the command output find a line that looks like the following:

/usr/lib/postgresql/9.0/bin/postgres -D /var/lib/postgresql/9.0/main -c unix_socket_directory=/var/run/postgresql -c config_file=/etc/postgresql/9.0/main/postgresql.conf

Once you have located the command to start PostgreSQL service, the following keys in it indicate the location of the database files:

  • The-D key is a database file structure directory;

  • The-s key with config_file option refers to main configuration file location, that file is usually named postgresql.conf;

  • The-c key with hba_file option refers to configuration file authentication parameters location, the file is usually named pg_hba.conf.

If configuration files aren’t explicitly placed in any other location, they are located in the top level of the DB directory.

Did this answer your question?