加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – template0和template1数据库意外丢失

发布时间:2020-12-13 18:09:39 所属栏目:百科 来源:网络整理
导读:我不知道是否需要template0和template1数据库模板才能创建空数据库.我删除它们是为了清理postgres.现在我无法创建任何新数据库.给我这个错误: ERROR: template database "template1" does not exist 我该怎样做才能让事情再次发生.我会非常感谢任何帮助. 幸
我不知道是否需要template0和template1数据库模板才能创建空数据库.我删除它们是为了清理postgres.现在我无法创建任何新数据库.给我这个错误:
ERROR:  template database "template1" does not exist

我该怎样做才能让事情再次发生.我会非常感谢任何帮助.

幸运的是我保留了postgres数据库,因为postgres用户需要登录到psql.因此,创建了template0和template1数据库:
create database template0 TEMPLATE postgres;

和template1相同.然后执行:

update pg_database set datistemplate=true  where datname='template0';

两个数据库都阻止我自己再次意外删除这些模板.

现在一切正常:)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读