postgresql 如何更改 Postgres 的维护数据库?

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

How do I change the maintenance database for Postgres?

databasepostgresqlmaintenancepgadmin

提问by gsiener

I'm running PostgreSQL version 9.0 on OSX version 10.6.6. Somehow one of my development databases has become the maintenance db, not postgres (this db also exists). I can't find any documentation on how to change/set the maintenance db back to postgres.

我在 OSX 10.6.6 版上运行 PostgreSQL 9.0 版。不知何故,我的一个开发数据库变成了维护数据库,而不是 postgres(这个数据库也存在)。我找不到任何关于如何将维护数据库更改/设置回 postgres 的文档。

I can't drop my development database because of this issue...

由于这个问题,我无法删除我的开发数据库...

回答by R?zvan Flavius Panda

You can change maintenance db from pgAdminbut you have to be disconnected from the database engine to be able to do that.

您可以更改维护数据库,pgAdmin但必须断开与数据库引擎的连接才能执行此操作。

First disconnect:

首先断开连接:

Then in the database server properties:

然后在数据库服务器属性中:

Choose the desired maintenance database:

选择所需的维护数据库:

回答by intgr

You're not entirely clear on this, but do you mean the "Maintenance DB" selection in pgAdmin III?

您对此并不完全清楚,但您的意思是 pgAdmin III 中的“维护数据库”选项吗?

Select the server in your "object browser" pane; right click -> Properties

在“对象浏览器”窗格中选择服务器;右键单击-> 属性

The fifth field is "Maintenance DB"

第五个字段是“维护数据库”

回答by dogankadriye

enter image description here

在此处输入图片说明

Maintenance db field is read-only , you can't change it.So you should keep your server properties somewhere and create new server with these properties and set maintenance db "postgres". Now you are able to drop database.

维护数据库字段是只读的,你不能改变它。所以你应该把你的服务器属性保存在某个地方,并用这些属性创建新服务器并设置维护数据库“postgres”。现在您可以删除数据库。

回答by GManika

The command line option is :

命令行选项是:

psql -U intelison -c "UPDATE pg_database SET datistemplate=false, datallowconn=true WHERE datname = '<your_database_name>'"