简体   繁体   中英

How do I change the maintenance database for Postgres?

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.

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

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

First disconnect:

Then in the database server properties:

Choose the desired maintenance database:

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

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

The fifth field is "Maintenance DB"

在此处输入图片说明

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.

命令行选项是:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM