Remove mildew odor from carpet by drying the air in the room and removing the mildew itself. The process requires removing the carpet and taking it to a sunny area for several days. Kill any remaining mildew spores by spraying with dilute hydrogen peroxide and drying the carpet.
Fix any water leaks that have led to the problem. Mildew requires moisture to grow, and a humid room provides enough water to encourage growth. Install a dehumidifier to dry the air. Open curtains to allow sunshine into the room. If the weather permits, open windows to allow fresh air inside the house.
Remove the carpet from the tack strip, and roll back to expose the backing. Use fans to keep air moving and dry the carpet.
Remove the carpet from the room and place it on a clean, dry driveway with the backing facing the sun. Sunlight helps to continue the drying process, kill spores and eliminate odors.
Mix one part hydrogen peroxide with five parts of water. Spray the back of the carpet with the solution to kill any remaining spores. Allow sufficient time for the rug to dry in the sun.
Move the carpet back inside the home. Use appropriate tools to stretch the carpet back in place, and attach it to the carpet tack strip. Use a steam cleaner to clean the carpet.