You can use [osm2pgsql][1] to get data into database. You can then modify stylefile default.style to get only the polygons you want into database.
You can find all necessary steps on [switch to osm page][2]. As you do not need the rendering part just read the parts that describe db setup and data import. In case you need to keep this db up to date also take a look at [osmosis][3].
[1]: http://wiki.openstreetmap.org/wiki/Osm2pgsql
[2]: http://switch2osm.org/serving-tiles/manually-building-a-tile-server/
[3]: http://wiki.openstreetmap.org/wiki/Osmosis