[GIS] Osm2pgsql failed due to error when I try to import data into PostgreSQL

databasenominatimopenstreetmaposm2pgsqlpostgresql

I am using the following link to install openstreetmap server on my ubuntu 14.04 server. I have followed their tutorial line by line and installed most of the dependencies and everything. When I try to import the North America's map data into my PostgreSQL database it is throwing an error. I am using this command to load all the data

osm2pgsql --slim  -d gis -C 16000 --number-processes 1 /usr/local/share/maps/planet/north-america-latest.osm.pbf

but it is throwing an error as you see on image.

Osm2pgsql failed due to ERROR: Error: Connection to database failed: FATAL: role 'azureuser' does not exist.

enter image description here

azureuser is the username of my terminal and when configuring my postgresSQL database I created a user 'openstreet' and database 'gis'. If you open the link you can also see the command to import data under the section Importing data into the database but that is not working for me. Could anyone help me with this error? I am not able to move forward from here

Best Answer

I have resolved this error:

The problem is still your pg_hba.conf file (/etc/postgresql/9.3/main/pg_hba.conf). This line:

local   all             postgres                                peer

Should be

local   all             postgres                                trust

After altering this file, don't forget to restart your PostgreSQL server. If you're on Linux, that would be sudo service PostgreSQL restart.

Once you have done this you need to change the Osm2pgql command. In this command my database name is gis and username is openstreet.

osm2pgsql --slim -U openstreet -d gis -C 16000 --number-processes 1 /usr/local/share/maps/planet/north-america-latest.osm.pbf