Recently had to reinstall SharePoint for our developer. He had a content database with a bunch of site collections in it and he wanted to keep it after the farm was reinstalled.


After reinstalling SharePoint:

  1. Re-attach the database in SQL Management Studio.
  2. Mount the content database in powershell and attach it to the web application by running the following command:
Mount-SPContentDatabase -Name <DatabaseName> -DatabaseServer <ServerName>
-WebApplication <URL> [-Updateuserexperience]

You should now see all the site collections that are in the database. This will also create the managed paths for each site collection. Note that if any of the managed paths are in use, the site collection will not be ‘imported’. In my case, I had to delete the site collection that was using ‘/’ and re-attach the content database.