And as a last supplement, here’s the exact command line statement I used. Note though that it uses –slim --drop and additionally –flat-nodes, since I don’t need (minutely) updates on my machine, and flat nodes to force putting the intermediate node cache on the SSD instead of loading the data in PostgreSQL. Despite warnings to only use this flat nodes option for global extracts, I have found it to work equally well for (small) country extracts. This may have to do with my SSD storage though, and may not be the case with a traditional hard drive. Additionally, I am using –hstore-all, since I need access to all keys.
You may need to make adjustments to suite your needs, especially take notice of the location and names of the (default) openstreetmap-carto style assumed here, if you use a different style or different folder structure, that will definitely need change:
osm2pgsql -d <YOUR_DATABASE_NAME> -U <YOUR_DATABASE_USERNAME> --create -G --hstore-all -W -l --slim --drop --flat-nodes 'data/nodes.bin' --style 'src/openstreetmap-carto/openstreetmap-carto.style' --tag-transform-script 'src/openstreetmap-carto/openstreetmap-carto.lua' 'data/<YOUR_PBF_FILE>.pbf'