If you are getting hit in the face by the dank smell of mold and mildew when opening a bathroom cabinet, look for a source of moisture. Unless the scent originates from the crawlspace or basement, more than likely something leaks. The repair might be as simple as replacing caulking around the sink, or it could be a leaking pipe. Nevertheless, you can get rid of a musty smell in a cupboard, but not until the cause is found and repaired.
Use Dry Ground Coffee to Absorb the Smell
After the source of the musty smell has been located and fixed, remove the contents of the cabinet and place a saucer of dry ground coffee inside for at least 24 hours. Sprinkle the coffee in the garden or flowerbed to enhance the soil instead of just throwing it away. Although the inside of the vanity will smell like coffee beans, it should no longer have the overwhelming stench of mold and mildew. Eventually the scent of coffee beans will dissipate and leave behind a fresh, clean aroma.
Neutralize the Odor with White Vinegar
If you do not have coffee on hand or do not want to deal with a lingering java scent, use white vinegar to get rid of the odor. Take everything out of the bathroom cabinet and add a cup of white vinegar. Leave it in the cupboard for 24 to 48 hours. It will neutralize the bad odor, and the smell of vinegar will fade very quickly after the bowl is removed. Do not pour it down the drain. Use it for cleaning purposes, or refresh your garbage disposal. Pour it into the disposal along with an orange peel before turning it on. Your bathroom cabinet and your disposer will smell incredibly fresh and clean.
Absorb the Musty Smell with Newsprint
Newspaper is good for more than just protecting a work surface. As long as the source of the odor has been remedied, it will absorb and remove a musty smell. Take everything out of the bathroom cabinet, and add several crumpled sheets of black and white newsprint. Leave it in the closed cupboard for at least 48 hours. The bad smell will be gone. Be sure to toss the papers into a recycling bin when finished.
Consider Replacing the Cabinet Floor
If the aforementioned methods to get rid of a musty smell in a bathroom cabinet do not work, the source of the odor could be in the floor of the cabinetry. If it is water damaged, consider replacing it with plywood of the same thickness. Cover it with peel and stick shelf paper to prevent possible water damage. Replacing the floor of the vanity should ultimately get rid of the problem.
Source: Professional Home Cleaning and DIY Home Improvement Experience