Recent studies have demonstrated that pain is partially regulated by the gut microbiota. However, the association of gut microbiota with painful diabetic neuropathy, a common complication of diabetes, remains unclear. Herein, we investigated whether the gut microbiota is associated with mechanical allodynia during the early stage of hyperglycemia in 7-week-old db/db mice. The db/db mice were intraperitoneally injected with metformin for 2 weeks. Using the von Frey test and gut microbiota analyses, we investigated the association of gut microbial changes with mechanical allodynia in 7-week-old mice. In db/db mice, colonic microbial community profiles were altered, and both unweighted and weighted UniFrac distances were reduced. Colonic genus-level abundances of Alloprevotella and Prevotellaceae_UCG-001 were positively correlated with mechanical allodynia in db/db mice, while the abundance of Odoribacter was negatively correlated. Intraperitoneal injection of metformin for 2 weeks alleviated mechanical allodynia in db/db mice but did not achieve an anti-diabetic effect. Metformin altered colonic microbial communities and increased weighted UniFrac distance in db/db mice, although its analgesic effect was not associated with specific bacteria. Additionally, alteration of small intestinal microbial community profiles and reduction in weighted UniFrac distance were observed in db/db mice, which were not affected by metformin. These results provide potential evidence of the association of the gut microbiota with mechanical allodynia during early-stage of hyperglycemia.