Why is graphite electrode used as anode in electrolyses of molten magnesium chloride
The electrode which is connected to the positive terminal of the battery (or the positively charged electrode) is known as the anode, while the electrode which is connected to the negatively terminal (or the negatively charged electrode) of the battery is known as the cathode.
So, in the electrolysis of molten MgCl2 using graphite electrodes, the electrode which is positively charged and towards which the Cl-ions will migrate will be the anode. Following will be the reaction which will occur at anode
2Cl- → Cl2 + 2e-
The electrode which is negatively charged and towards which magnesium ions will migrate will be the anode. Following will be the reaction which will occur at cathode
Mg2+ + 2e- → Mg
Thus, we will get magnesium at the cathode and chlorine at the anode.