Patients with diabetes mellitus (DM) suffer more risks from diabetic encephalopathy such as cognitive dysfunction and depressive-like behaviors. Numerous studies show that ER (endoplasmic reticulum) stress and inflammation play important roles in the development of diabetic encephalopathy. Gastrodin (Gas), one major component of Gastrodia elata, is traditionally used in central nervous system disorders and is believed to possess anti-inflammatory, anti-apoptotic, and other neuroprotective effects. This present study aims to explore the protective effects of Gas on diabetic encephalopathy. Gas was administrated daily (70 and 140 mg/Kg) for 12 weeks. Meanwhile, the fasting blood glucose and body weight of db/db mice were measured every two weeks. After Gas treatment, the Morris water maze (MWM) test and novel object recognition (NOR) test were performed to assess the learning and memory functions of db/db mice, and the forced swim test was performed to evaluate depressive-like behaviors of db/db mice. Additionally, the expression of ER stress and Nucleotide binding and oligomerization domain-like (Nod) receptor family pyrin domain-containing 3 (NLRP3) inflammasome related proteins were evaluated by using Western blot. Our study suggested that Gas attenuated blood glucose levels and dyslipidemia of db/db mice. It has been shown that Gas could improve learning and memory function and depressive-like behaviors of db/db mice. Moreover, Gas inhibited ER stress and NLRP3 inflammasome activation in the hippocampus. Taken together, this study demonstrates that Gas attenuates the diabetic encephalopathy by inhibiting ER stress and NLRP3 inflammasome activation.