Dry the carpet as thoroughly as possible. Set up dehumidifiers or fans and open windows to increase ventilation.
Vacuum the carpet to remove as much mold residue as possible. Dispose of the vacuum cleaner bag or empty the vacuum cleaner outside so you do not release the mold spores near the carpet.
Mix two parts white vinegar with eight parts water in a spray bottle.
Spray the vinegar and water liberally across the carpet. Allow the solution to dry. If you still smell the mildew, repeat.
Sprinkle baking soda across the carpet once it is completely dry and the smell is gone or minimal.
Let the baking soda sit on the carpet for at least one hour, then vacuum thoroughly.