Oxidation is the loss of electrons or an increase in oxidation state by a molecule, atom, or ion. Reduction is the gain of electrons or a decrease in oxidation state by a molecule, atom, or ion.
Here, in formation of MgCl2, Mg looses two electron and get oxidised while two Cl atom gains one electron each and get reduced.