PostgreSQL 数据文件位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14161184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 00:41:35  来源:igfitidea点击:

PostgreSQL data file location

postgresqlpostgresql-9.2

提问by sheidaei

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?

我在 Mac 上使用 PostgreSQL,我使用命令行创建了几个数据库。我正在查看 /Library/PostgreSQL/9.2/data 并且我看不到任何 .dat 文件。我在寻找数据文件的错误位置吗?

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

我使用了以下命令:ps auxw | grep postgres | grep -- -D 如前所述,Linux 上的 PostgreSQL 数据库默认位置,它为我提供了 /Library/PostgreSQL/9.2/data 目录。

Any ideas?

有任何想法吗?

回答by sheidaei

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

两者都产生相同的结果。第一个通过 postgresql,第二个是命令行。感谢@a_horse_with_no_name

回答by Mike Sherrill 'Cat Recall'

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.

PostgreSQL 允许您将数据存储在文件系统中相对任意的位置。默认的位置,您可以用得到show data_directory是不是故事的全部