The invention relates to a preparation method of a biological ceramic coating rich in calcium and phosphate phases on the surface of magnesium alloy, comprising the following steps of: adding (C6H5O7)2Ca3.4H2O and Na3PO4 to deionized water, and simultaneously adding KOH, NH4HF2, N(CH2CH2OH)3, C3H8O3 and H2O2 to prepare an electrolyte with a certain concentration ratio of calcium and phosphate; disposing the magnesium alloy in the electrolyte as an anode which is prepared through micro arc oxidation energization reaction. The calcium-phosphate ceramic coating obtained by the preparation methodconsists of three layers of a loose layer, a transition layer and a compact layer, wherein the surface of the loose layer consists of a plurality of uniformly distributed micropores, the transition layer is between the loose layer and the compact layer, and the compact layer and a substrate body form good metallurgical bonding; therefore, the coating has high rigidity, high density, high bonding force and good corrosion resistance and abrasion resistance; simultaneously, the mouse acute systemic toxicity test indicates that the coating has good biocompatibility, and the simulated body fluid soaking test indicates that the coating has good biological activity.