The invention discloses a method for preparing a magnesium-based ceramic coating by micro-arc oxidation-electrophoretic deposition. The method comprises the following steps of: immersing preheated magnesium alloy taken as an anode in an electrolyte, taking a micro-arc oxidation stainless steel electrolytic cell as a cathode, adopting a direct-current pulsed micro-arc oxidation device, carrying out micro-arc oxidation for 10-25 minutes under the conditions that the electric current is 10-20A/dm<2>, the duty ratio is 37.5-50%, and the temperature of the electrolyte is 20-30 DEG C, taking out the anode, naturally drying, thus obtaining magnesium alloy subjected to micro-arc oxidation; immersing the magnesium alloy subjected to micro-arc oxidation and taken as the anode in electrophoretic deposition liquid, taking the stainless steel electrolytic cell as the cathode, adopting a pulsed power supply, carrying out electrophoretic deposition treatment for 10-30 minutes under the conditions that the voltage is 250-350V, and the duty ratio is 37.5-50%, naturally cooling, thus obtaining the magnesium-based ceramic coating. The adhesive force of the biological nanometer coating is obviously enhanced, the toughness and the corrosion resistance of the coating are improved, and the coating has certain biological activity.