postgresql:如何删除数据库集群

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6992961/
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-09-10 23:03:54  来源:igfitidea点击:

postgresql: how to delete database cluster

postgresql

提问by matthiash

I have used the command initdb to create a database cluster:

我已经使用命令 initdb 创建了一个数据库集群:

sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'

If I want to delete this database cluster, can I simply remove the folder defaultdb? Or is there some command I should use?

如果我想删除这个数据库集群,我可以简单地删除文件夹defaultdb吗?或者我应该使用一些命令吗?

回答by francs

Yes, If you want to delete the database cluster you just created just remove the data directory /opt/local/var/db/postgresql83/defaultdb.

是的,如果要删除刚刚创建的数据库集群,只需删除数据目录/opt/local/var/db/postgresql83/defaultdb

By the way, if the PG server is running, shut it down before.

顺便说一句,如果PG服务器正在运行,请先关闭它。

回答by Javier Parra

If you are using something debian-like, the cleanest way is to run pg_dropcluster

如果你正在使用类似 debian 的东西,最干净的方法是运行pg_dropcluster

pg_dropcluster 9.4 main