White button mushroom polysaccharide (WMP) has various health-promoting functions. However, whether these functions are mediated by gut microbiota has not been well explored. Therefore, this study evaluated the anti-aging capacity of WMP and its effects on the diversity and composition of gut microbiota in D-galactose-induced aging mice. WMP significantly improved locomotor activity and the spatial and recognition memory of the aging mice. It also alleviated oxidative stress and decreased the pro-inflammatory cytokine levels in the brain. Moreover, WMP increased α-diversity, the short-chain fatty acid (SCFA) level and the abundance of beneficial genera, such as Bacteroides and Parabacteroides. Moreover, its effect on Bacteroides at the species level was further determined, and the enrichments of B. acidifaciens, B. sartorii and B. stercorirosoris were found. A PICRUSt analysis revealed that WMP had a greater impact on the metabolism of carbon, fatty acid and amino acid, as well as the MAPK and PPAR signaling pathway. In addition, there was a strong correlation between the behavioral improvements and changes in SCFA levels and the abundance of Bacteroides, Parabacteroides, Mucispirillum and Desulfovibrio and Helicobacter. Therefore, WMP might be suitable as a functional foods to prevent or delay aging via the directed enrichment of specific species in Bacteroides.