Exporting a lot of users from an older version of Alfresco to a new one and keeping their hash passwords?
or updating the database with the users
I am missing a question here - usually they begin with "How", "Why", "What" or "Can someone explain..:"
Typically, you can update an Alfresco system in-place and upgrade the schema in the database without having to export (parts of) the data - in fact Alfresco will do the schema upgrade for you. Of course it may depend of what kind of an old version you are talking - a pre-historically old one (2.x), an extremely old one (3.x), a grandfather version (4.x) or just one of the recent ones (5.x). Bigger steps may obviously involve more work/risk, especially if you are using Community Edition where there are fewer intensively supported/tested upgrade paths.
Retrieving data ...