At present, there are few studies on microbial corrosion of magnesium anode materials that provide protection for oil pipelines in tidal flat environment. In view of an abnormal failure of magnesium anodes in oil pipelines in a tidal flat mud environment, the influence of the change in water content in the beach mud on the corrosion of AZ31B magnesium anode by sulfate-reducing prokaryote (SRP) was investigated by electrochemical methods, weight loss and surface analysis techniques. SRP can grow well in a tidal flat mud environment and cause microbial corrosion of magnesium alloy. The results show that with the increase in water content, the number of SRP cells in the mud increased, that the corrosivity of tidal flat muds was enhanced and that the corrosion rate of AZ31B magnesium anode was accelerated: compared with the corrosion rate of 0.554 mm/y in 40% water content, the corrosion rate of magnesium alloy samples in 60% water content is as high as 1.38 mm/y.