How to export/import categories and keep their IDs?

Using a plugin doesn’t keep the IDs of the categories and exporting/importing of the wp_terms and wp_term_taxonomy tables only works on categories without parents, it seems. The admin panel still shows there are many pages of categories, but they are all empty.

Solutions Collecting From Web of "How to export/import categories and keep their IDs?"