This study analyzed the composition of the microbial community in raw milk and its effects on flavor compounds by comparing samples from cows raised on pasture (PXN) and in housing (HXN). In August 2023, nine raw milk samples from Holstein cows were collected from a pasture in the Xilin Gol League, Inner Mongolia, China, and labelled as the PXN group. Simultaneously, nine raw milk samples were collected from Holstein cows raised by individual farmers in the region and labelled as the HXN group.