The invention relates to an environment-friendly magnesium alloy micro-arc oxidation electrolyte and a micro-arc oxidation method. The electrolyte includes: phytate or phytic acid 5g / L-20g / L, and one or more of the following substances: carbonate 5g / L-20g / L, silicate 5g / L-50g / L, boric acid Or borate 5g / L~50g / L, aluminate or aluminum hydroxide 5g / L~50g / L. It is operated according to the following steps: 1) Pretreatment: grinding, degreasing and pickling. 2) Micro-arc oxidation: In phytate (or phytic acid), add one or more substances of carbonate, silicate, boric acid or borate, aluminate (or aluminum hydroxide), and use alkali Metal hydroxide or ammonia water adjusts the pH value of the solution to 10-14, and then micro-arc oxidation. 3) post-processing. The anodic oxidation electrolytic solution used in the present invention does not contain Cr6+, F-, PO43-, even very little strong alkali is used, and there is no pollution to the environment. The obtained film layer has smooth surface, small hole diameter, good corrosion resistance and ceramic appearance. The raw materials of the method of the invention are easy to obtain and are suitable for industrial production.