Magnesium chloride is an ionic compound made up of magnesium ions `(Mg^(2+))` and chloride ions `(Cl^(-))` . Magnesium ions has a valency (or charge ) of `2+` wheareas choride ion has a valency (or charge) of 1-, the formula for magnesium chloride can be worked out as follows :
Thus, the formula of magnesium chloride is `MgCl_(2)`.