Carbon dots (CDs) with high quantum yield (QY), low toxicity and good biocompatibility are the major quests of biomedical research. In this paper, we develop a green, simple hydrothermal approach to synthesize water-soluble, nontoxic, highly photoluminescent carbon nanodots (CNDs) from Metronidazole, which possess selective antibacterial activity against obligate anaerobes for the first time. Metronidazole was used as a sole precursor to prepare CNDs at 250 °C (CNDs-250) for 8 h. After the CNDs-250 with an average size of 2.9 nm, consisting of a highly carbon crystalline core and various surface groups were obtained, the formation and fluorescence mechanisms of CNDs were further explored by adjusting the reaction time and reaction temperatures, respectively. Biological experimental data proved that CNDs-250 can only inhibit the growth of obligate anaerobes, such as Porphyromonas gingivalis (P. gingivalis) directly, instead of further functionalization. Besides, CNDs-250 with a QY around 28.1% exhibit an obvious excitation-dependent emission, which will be conducive to multicolor bioimaging. And it may not only develop a new approach for researchers to prepare multifunctional CDs, but also provide a valuable strategy for the theranostics of some diseases as well as other fields.