The effect of oxalic acid (OA) etching on the formation mechanism and corrosion performance of in-situ steam Mg−Al layered double hydroxide (LDH) coatings on AM50 Mg alloy was investigated by exposing the intermetallic compounds (β-Mg17Al12 and AlMn) on the surface of the alloy. The results demonstrated that the presence of OA led to an increased fraction of intermetallic compounds on the Mg substrate. Mg−Al LDH nucleated and grew around the Al−Mn phase. The best corrosion resistance of LDH coating was obtained with the maximum thickness at a pickling time of 45 s, and the corrosion current density was reduced by three orders of magnitude compared to the substrate. Finally, the formation mechanism of Mg−Al LDH coating on AM50 Mg alloy was proposed.