Abstract 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