Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres Osm2pgsql Error: role does not exist

I've been setting up osm2pgsql to convert .osm files to be usable in Postgres. I have now tried the following statement:

osm2pgsql --merc -d sa sa.osm

I am given the following error: "Connection to database failed: FATAL: role "myUsername" does not exist

I have read up about this kind of error which is usually run into when using Postgres. I have created a new role in Postgres but still the error persists.

Any suggestions?

like image 539
nix Avatar asked Dec 22 '22 09:12

nix


2 Answers

You didn't specify -U|--username switch, so osm2pgsql gets current username from terminal (unless you set PGUSER environment variable). Error message looks very clear, telling that role named myUsername does not exist in your database cluser. Note that:

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

will produce two different roles:

SELECT rolname FROM pg_roles;
  rolname   
------------
 postgres
 myUsername
 myusername
(3 rows)
like image 104
Grzegorz Szpetkowski Avatar answered Dec 26 '22 22:12

Grzegorz Szpetkowski


I know this is an old question but things have changed in OSM and this answer appears to be at the top of a Google search

Use this:

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

for example

/usr/bin/install-postgis-osm-user.sh gis barrythefish
like image 37
Fuzzy Avatar answered Dec 26 '22 23:12

Fuzzy