createdb / pg_restore has error: must be owner of extension

createdb / pg_restore has error: must be owner of extension

我收到这个错误:

pg_restore: [archiver (db)] Error while PROCESSING TOC: 
pg_restore: [archiver (db)] Error from TOC entry 4034; 0 0 COMMENT EXTENSION pg_trgm  
pg_restore: [archiver (db)] could not execute query: ERROR: 
must be owner of extension pg_trgm
Command was: COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';

当我 运行 这个命令时:

PGPASSWORD="$db_pwd" createdb -U "$db_user" -h "$db_host" -p 5432 --no-password -e "$db_name"

我该如何解决?我认为正确的做法是让自己成为 pg_trgm 扩展的所有者,但是怎么做呢?

导致此错误的不是 createdb 命令,而是 pg_restore.

这意味着您以非超级用户身份从扩展名为 pg_trgm 的数据库中恢复了转储。

扩展本身恢复为

CREATE EXTENSION IF NOT EXISTS pg_trgm;

所以如果扩展名已经存在,这不会导致错误,但以下

COMMENT ON EXTENSION pg_trgm IS '...';

对于非超级用户将导致错误。

您可以安全地忽略此错误。