Microglia activation contributed to the development of Parkinson's disease (PD)-associated cognitive impairment and targeting microglia may be a promising strategy for improving the cognitive function in PD. O-GlcNAclytion is a novel protein post-translational modification with cognitive enhancing effects. This study aimed to investigate the effects of Thiamet-G (TMG), an O-GlcNAcase inhibitor that can increase the intracellular O-GlcNAclytion levels, on PD-associated cognitive impairment and the mechanism related to microglia activation. A PD mouse model was established using rotenone (ROT) and the cognitive functions of these mice were investigated by behavioral tests. The anti-inflammatory effects of TMG were tested in the BV2 microglia cells. TMG treatment significantly improved the cognitive function in the ROT-induced PD mouse model as evidenced by the Y-maze test and objective recognition test. Histological studies showed that TMG decreased the reactive microglia via increasing the total protein O-GlcNAclytion levels in the hippocampus of the PD mice. In the in vitro studies, TMG inhibited ROT-induced inflammation via decreasing the pro-inflammatory cytokines such as TNF-α, IL-1β and IL-6 in BV2 microglia cells. Bioinformatic analysis revealed that STING, a core protein in the innate immunity regulation, might be a novel target of O-GlcNAclytion. The immunoprecipitation experiments further confirmed that TMG inhibited STING phosphorylation via increasing O-GlcNAcylation. Taken together, TMG might ameliorate PD-associated cognitive impairment via increasing O-GlcNAcylation of STING in microglia, which provided evidence supporting that inhibiting the inflammatory response of microglia by elevating the O-GlcNAclytion levels might be an effective strategy for improving the cognitive function in PD.