Genetic variation in CLDN19, CNNM2, FXYD2, SLC41A2, and TRPM6 significantly influenced diabetes risk (p < 0.05), and for CNNM2, FXYD2, SLC41A2 and TRPM6 this risk was completely mediated by serum magnesium levels. Here, TRPM6 is linked to diabetes mellitus.