Locating the database server files
Database server files are initially stored in a location referred to as the data
directory. Additional data files may also be stored in tablespaces if any exist.
In this recipe, you will learn how to find the location of these directories on a given database server.
Getting ready
You’ll need to get OS access to the database system, which is what we call the platform on which the database runs.
How to do it...
If you can connect using psql
, then you can use this command:
postgres=# SHOW data_directory;
data_directory
-----------------------
/opt/postgres/data/
If not, the following are the system’s default data
directory locations:
- Debian or Ubuntu systems:
/var/lib/postgresql/MAJOR_RELEASE/main
- Red Hat RHEL, CentOS, and Fedora:
/var/lib/pgsql/data/
- Systems deployed with Trusted Postgres Architect (TPA):
/opt/postgres/data
- Windows:
C:\Program Files\PostgreSQL\MAJOR_RELEASE...