How to confirm presence of Mg2+ ions
Add NaOH and observe ppt formed
MgCl2 + 2NaOH -> Mg(OH)2 + 2NaCl
Magnesium hydroxide is sparingly soluble, so a thick white ppt would be seen
Mg2+ (aq) + 2OH- (aq) -> Mg(OH)2 (s)
barium hydroxide does not form a ppt, so a colourless solution would be seen