This study aimed to understand the changes in the milk and gut microbiota of dairy cows with mastitis, and to further explore the relationship between mastitis and the microbiota. In this study, we extracted microbial DNA from healthy and mastitis cows and performed high-throughput sequencing using the Illumina NovaSeq sequencing platform. OTU clustering was performed to analyze complexity, multi-sample comparisons, differences in community structure between groups, and differential analysis of species composition and abundance. The results showed that there were differences in microbial diversity and community composition in the milk and feces of normal and mastitis cows, where the diversity of microbiota decreased and species abundance increased in the mastitis group. There was a significant difference in the flora composition of the two groups of samples (P<0.05), especially at the genus level, the difference in the milk samples wasSphingomonas(P< 0.05) andStenotrophomonas(P< 0.05), the differences in stool samples wereAlistipes(P< 0.05),Flavonifractor(P< 0.05),Agathobacter(P< 0.05) andPygmaiobacter(P< 0.05). In conclusion, the microbiota of the udder and intestinal tissues of dairy cows suffering from mastitis will change significantly. This suggests that the development of mastitis is related to the endogenous pathway of microbial intestinal mammary glands, but the mechanisms involved need further study.