  Magnesium abundances of cool stars with different metallicities are important
for understanding the galactic chemical evolution. This study tests atomic data
used in stellar magnesium abundance analyses. We evaluate non-local
thermodynamical equilibrium (NLTE) line formation for Mg I using the most
up-to-date theoretical and experimental atomic data available so far and check
the Mg abundances from individual lines in the Sun, four well studied A-type
stars, and three reference metal-poor stars. With the adopted gf-values, NLTE
abundances derived from the Mg I 4703 A, 5528 A, and Mg Ib lines are consistent
within 0.05 dex for each A-type star. The same four Mg I lines in the solar
spectrum give consistent NLTE abundances at $\log N_{\rm Mg}/N_{\rm H} =
-4.45$, when correcting the van der Waals damping constants inferred from the
perturbation theory. Inelastic Mg+H collisions as treated by Barklem, Belyaev,
Spielfiedel, Guitou, and Feautrier serve as efficient thermalizing process for
the statistical equilibrium of Mg I in the atmospheres of metal-poor stars. The
use of the Mg+H collision data improves Mg abundance determinations for HD
84937 and HD 122563, though does not remove completely the differences between
different lines.
