If you want to export your products and categories from one database to be able to import the data to completely new one, the categories IDs will not be the same, they will be automatically created.
If you need to import your products and categories, you can use category names and the same category free will be created after import. It is possible using the application called Store Manager for Magento. There is 14-day free version of the software which you can download here-
If I misunderstood you and you need something else, let me know so I could think on suitable solution for you.