The invention discloses an electrolyte for micro-arc oxidation of magnesium alloys to prepare ceramic layers, and a corresponding process method thereof. The electrolyte contains deionized water, sodium hexametaphosphate and additives, wherein the additives mainly include fluorides, a colorant and alkali metal hydroxides. The content of the sodium hexametaphosphate is 30-70 g/L, the content of the fluorides is 2-12 g/L, the content of the colorant is 2-10 g/L, and the pH value of the electrolyte is 7-10. The electrolyte is relatively low in system alkalinity, is a weak alkaline electrolyte for micro-arc oxidation, and can effectively reduce the process complexity of a water washing process in a micro-arc-electrophoresis production line, shorten the production line process, reduce the sewage discharge, and reduce the production cost; and once the electrolyte provided by the invention is adopted for carrying out the micro-arc oxidation of magnesium alloys, prepared ceramic layers have beautiful and decorative properties, so that a problem that ceramic layers prepared through the micro-arc oxidation of magnesium alloys are single in color is solved.