【问题标题】:Can the encoding of the default admin (postgres) be changed?可以更改默认管理员(postgres)的编码吗?
【发布时间】:2014-07-10 23:06:06
【问题描述】:

我正在尝试从 9.2 升级到 9.3,pg_upgrade 失败,因为 9.2 postgres (admin) db 是 SQL_ASCII 而新的 9.3 postgres (admin) 实例是 UTF-8。

我无法删除 'postgres' 数据库,因为它是管理实例,所以我无法使用 UTF-8 重新创建。

我这样做对吗?

非常感谢您的建议。

谢谢。

【问题讨论】:

  • 为什么不能删除(新的)postgres 数据库?该数据库没有什么特别之处。

标签: postgresql


【解决方案1】:
  • 您仍然可以删除数据库。在 Linux 下,以下 shell 命令应该可以解决问题(作为 postgres 用户发出,在 root shell 中使用 su - postgres):

    postgres$ pg_dump postgres > pg.sql
    postgres$ dropdb postgres
    postgres$ createdb -O postgres -E UTF8 postgres
    postgres$ psql < pg.sql
    
  • 或者,您可以欺骗目录认为数据库是 UTF8 格式的。这适用于空的postgres 数据库(默认为空)

    postgres$ psql 
    postgres=# UPDATE pg_database SET encoding = pg_char_to_encoding('UTF8') WHERE datname = 'postgres';
    

【讨论】:

  • 非常好,替代方案(更新)运行良好,非常感谢!
猜你喜欢
  • 1970-01-01
  • 2012-09-18
  • 1970-01-01
  • 1970-01-01
  • 2022-03-17
  • 1970-01-01
  • 2016-11-21
  • 2019-06-15
  • 1970-01-01
相关资源
最近更新 更多