The study investigated the association between the level of 25-hydroxyvitamin D (25(OH)D) and the intestinal microflora in children with infectious mononucleosis caused by the Epstein-Barr virus. 99 children were classified according to the level of 25(OH)D into three groups, and stools from 60 children were analyzed by sequencing the 16S rRNA gene. The level of 25(OH)D was positively correlated with the percentages of NK cells and B cells and negatively with IL-17, IL-β17, TNF-α, T cells and CTL cells (all p < 0.01). The suboptimal 25(OH)D group had a higher representation of Bacillota and Proteobacteria, a lower representation of Bacteroidetes and Actinobacteria compared to the optimal group. In the suboptimal group, the abundances of Acinetobacter (LDA = 2.53, p = 0.02), Epulopiscium (LDA = 2.76, p = 0.02) and Collinsella (LDA = 3.16, p = 0.04) increased, while Anaerostipes (LDA = 2.6, p = 0.042), Helicobacter (LDA = 2.79, p = 0.041) and Desulfovibrio (LDA = 2.76, p = 0.02). Anaerostipes correlated positively with 25(OH)D (r = 0.335, p < 0.001), Acinetobacter negatively (r = -0.303, p < 0.001). Improving vitamin D deficiency may help maintain normal gut microflora and improve immune dysregulation in MI.