Patients with type 2 diabetes mellitus (T2DM) have a higher risk to develop cognitive impairment. Several studies reported the potential roles of vitamin D in prevention of cognitive impairment, but the mechanism remains unclear. The present study aims to investigate the protective effects of vitamin D 3 on cognitive impairment in db/db mice and to explore the possible mechanism. Twelve‐week‐old male db/db mice were randomly administrated with low, medium, and high dose of vitamin D 3 (LVD, MVD, and HVD groups, respectively) and equivalent volume vitamin D 3 solvent (corn oil, DM group) intragastrically. Eight age‐matched db/m mice were given equivalent volume corn oil as normal group. After 16 weeks of vitamin D 3 treatment, the concentrations of fasting serum glucose in three vitamin D 3 groups (especially the 1,000 IU/kg·bw dose) were significantly decreased compared with DM group. Pathology revealed that the neuron damage was reduced in vitamin D 3 groups. MVD intervention significantly shortened the escape latency on day 5 and extended time in the target quadrant. Mice in HVD group had significantly higher exploration time and discrimination index compared with the DM group mice. Moreover, vitamin D 3 treatment has increased the phosphorylation of cAMP‐response element‐binding protein and the expression of brain‐derived neurotrophic factor and vitamin D receptor. This treatment, meanwhile, has decreased the expression of tumor necrosis factor‐α, the phosphorylation of inhibitor kappa Bα (IκBα), and nuclear factor‐κB p65 (NF‐κB p65) in the hippocampus of db/db mice. These results suggest that vitamin D 3 alleviated cognitive impairment in the hippocampus of db/db mice. Down‐regulation of the NF‐κB signaling pathway‐related proteins IκBα and p65 might be one of the possible mechanisms.