Microbial induced concrete corrosion (MICC) is the primary deterioration affecting global sewers. Disentangling ecological mechanisms in the sewer system is meaningful for implementing policies to protect sewer pipes using trenchless technology. It is necessary to understand microbial compositions, interaction networks, functions, alongside assembly processes in sewer microbial communities. In this study, sewer wastewater samples and microbial samples from the upper part (UP), middle part (MP) and bottom part (BP) of different pipes were collected for 16S rRNA gene amplicon analysis. It was found that BP harbored distinct microbial communities and the largest proportion of unique species (1141) compared to UP and MP. The community in BP tended to be more clustered. Furthermore, significant differences in microbial functions existed in different spatial locations, including the carbon cycle, nitrogen cycle and sulfur cycle. Active microbial sulfur cycling indicated the corrosion risk of MICC. Among the environmental factors, the oxidation‒reduction potential drove changes in BP, while sulfate managed changes in UP and BP. Stochasticity dominated community assembly in the sewer system. Additionally, the sewer microbial community exhibited numerous positive links. BP possessed a more complex, modular network with higher modularity. These deep insights into microbial ecology in the sewer system may guide engineering safety and disaster prevention in sewer infrastructure.