Micro arc oxidation-Polydopamine (MAO-PDA) composite coating is a functional corrosion resistant coating formed on the surface of magnesium alloy by combining MAO to form a porous ceramic layer and the spontaneous oxidation polymerization characteristics of PDA. The MAO-PDA coating is environmentally friendly and modifiable, providing a basic film layer for achieving self-warning, self-healing, conductivity and other modification functions, which has attracted widespread attention. A new type of MAO-PDA composite coating with good corrosion resistance was deposited on the surface of magnesium alloy by photocatalysis, which expanded the application range of magnesium alloy MAO surface treatment. Surface morphology, coating adhesion and corrosion resistance of the composite coating are characterized. Combined with Density functional theory (DFT) calculation, the possible mechanism is explored. The results indicate that the MAO layer containing Mg2TiO4 exhibits fewer pores and can better deposit PDA under ultraviolet (UV) light conditions, forming a magnesium alloy MAO-PDA composite coating with good corrosion resistance and modification friendliness. Band structure calculations confirm the photocatalytic effect of Mg2TiO4 under UV irradiation. As a result of the photocatalytic effect, reactive oxygen species (ROS) were generated in the pores and on the surface of the MAO sample, thus accelerating the local deposition of PDA.