9

I am using PostgreSQL on Mac, I have created several databases using command line. I am looking into /Library/PostgreSQL/9.2/data and I can not see any .dat file. Am I looking into the wrong place for data files?

I have used the following command: ps auxw | grep postgres | grep -- -D as mentioned PostgreSQL database default location on Linux and it gives me the /Library/PostgreSQL/9.2/data directory.

Any ideas?

Community
  • 1
  • 1
sheidaei
  • 9,842
  • 20
  • 63
  • 86
  • 4
    `select setting from pg_settings where name = 'data_directory'` shows you the real path of the data directory (you must be connect to PostgreSQL as a superuser) –  Jan 04 '13 at 16:59
  • Do not know about Mac. If this can help, in my Linux box they are located under /var/lib/pgsql/data/. Anyway, the files are only visible for the user postgresql. May be your files are there but hidden for your current user. – jap1968 Jan 04 '13 at 17:04

2 Answers2

14
select setting from pg_settings where name = 'data_directory'

and

ps auxw | grep postgres | grep -- -D 

both generate the same result. The first one through postgresql, second one command line. Thanks to @a_horse_with_no_name

Dave Liepmann
  • 1,555
  • 1
  • 18
  • 22
sheidaei
  • 9,842
  • 20
  • 63
  • 86
3

PostgreSQL lets you store data in relatively arbitrary locations in the filesystem. The default location, which you can get with show data_directory, isn't the whole story.

Community
  • 1
  • 1
Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185