Diabetes mellitus is characterized by having a disorder of glucose metabolism. The types of diabetes mellitus include type 1 diabetes mellitus, type 2 diabetes mellitus, gestational diabetes mellitus, and other specific types of diabetes mellitus. Many risk factors contribute to diabetes mellitus mainly including genetics, environment, obesity, and diet. In the recent years, gut microbiota has been shown to be linked to the development of diabetes. It has been reported that the gut microbiota composition of diabetic patients is different from that of healthy people. Although the mechanism behind the abnormality remains to be explored, most hypotheses focus on the inflammation response and leaky gut in relation to the changes in production of endotoxins and metabolites derived from the intestinal flora. Consequently, the above-mentioned abnormalities trigger a series of metabolic changes, gradually leading to development of hyperglycemia, insulin resistance, and diabetes. This review is (i) to summarize the differences in gut microbiota between diabetic patients and healthy people, (ii) to discuss the underlying mechanism(s) by which how lipopolysaccharide, diet, and metabolites of the gut microbiota affect diabetes, and (iii) to provide a new insight in the prevention and treatment of diabetes.