How to identify your postgres data directory?

This blog post aims at discussing how you can figure out which directory postgres is using to store data. 

In order to get started off, you will first need to log in to the interactive monitor of the database as the systems postgres user. 

In the line below, psql is the command to enter the interactive monitor, and -u postgres tells sudo to execute psql as the system’s postgres user:

sudo -u postgres psql

Once you’ve entered the monitor, enter the following command to list the data directory:

SHOW data_directory;

Output

data_directory ------------------------------ /var/lib/postgresql/9.5/main (1 row)

That’s all for this blog post! I hope that you learned something new. ☺️

Previous
Previous

How to remove a host key from ssh known_hosts file?

Next
Next

How to troubleshoot disk space issues - linux?