Postgres Osm2pgsql错误:角色不存在

时间:2011-08-25 20:37:28

标签: postgresql openstreetmap

我一直在设置osm2pgsql来转换.osm文件以便在Postgres中使用。 我现在尝试了以下声明:

osm2pgsql --merc -d sa sa.osm

我收到以下错误: “与数据库的连接失败:致命:角色”myUsername“不存在

我已经了解了使用Postgres时常遇到的这种错误。我在Postgres中创建了一个新角色但仍然存在错误。

有什么建议吗?

2 个答案:

答案 0 :(得分:9)

您没有指定-U|--username切换,因此osm2pgsql从终端获取当前用户名(除非您设置PGUSER环境变量)。错误消息看起来非常清楚,告诉您数据库cluser中不存在名为myUsername的角色。请注意:

CREATE ROLE myUsername LOGIN;    -- creating role myusername
CREATE ROLE "myUsername" LOGIN;  -- creating role myUsername

将产生两个不同的角色:

SELECT rolname FROM pg_roles;
  rolname   
------------
 postgres
 myUsername
 myusername
(3 rows)

答案 1 :(得分:1)

我知道这是一个老问题,但OSM中的情况发生了变化,这个答案似乎是谷歌搜索的首位

使用此:

/usr/bin/install-postgis-osm-user.sh the-database-here your-username-here

例如

/usr/bin/install-postgis-osm-user.sh gis barrythefish
相关问题