PostgreSQL 更改数据目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37901481/
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
PostgreSQL change the data directory
提问by guyd
I'm on Debian 8 and want to have another than the default directory for my databases. I have a vanilla install of PostgreSQL 9.4 (so no user databases yet). I found this http://climber2002.github.io/blog/2015/02/07/install-and-configure-postgresql-on-ubuntu-14-dot-04/about configuring a new data directory. Is this the correct way for doing this (or not)?
我在 Debian 8 上,想要为我的数据库设置一个默认目录以外的目录。我有一个 PostgreSQL 9.4 的 vanilla 安装(所以还没有用户数据库)。我发现这个http://climber2002.github.io/blog/2015/02/07/install-and-configure-postgresql-on-ubuntu-14-dot-04/关于配置一个新的数据目录。这是(或不是)这样做的正确方法吗?
Thanks.
谢谢。
回答by Fabrizio Mazzoni
Yes. Stop the server service postgresql stop
, create the new directory and chown
it to postgres, edit /etc/postgresql/9.4/main/postgresql.conf
changing data_directory
to the new directory. Initiate the directory with initdb -D /new_dir
and then restart the postgresql server.
是的。停止服务器service postgresql stop
,创建新目录并将chown
其发送到 postgres,编辑/etc/postgresql/9.4/main/postgresql.conf
更改data_directory
到新目录。启动目录,initdb -D /new_dir
然后重新启动 postgresql 服务器。