You can use the deodorizing agents to kill the mold and mildew on the carpet, as explained in this guide. The simplest way is to sprinkle some baking soda powder around the mold and mildew area, and then wait for a few hours to let it work. After that, brush off the area and vacuum it to remove mold and mildew from your carpet.