Endophytic fungi have played a very important role in influencing the quality and quantity of bioactive compounds of medicinal plants through specific fungus-host interactions. In medicinal licorices root, a total of 2,118,633 effective sequences and 1,063 effective operational taxonomic units (OTUs) with 97% identity were obtained by high-throughput sequencing. A total of 8 phyla and 140 genera were annotated, among them, the phylum Ascomycota and Basidiomycota, and the genera Fusarium, Paraphoma and Helminthosporium were significantly dominant. Moreover, Wilcoxon rank sum test showed that the Shannon index was significantly different distribution between Glycyrrhiza uralensis and Glycyrrhiza inflata, especially 0-20cm at the root depth, the Chao1 index in Glycyrrhiza inflata was significantly affected by root depth, and there were significant differences in beta diversity between Glycyrrhiza uralensis and Glycyrrhiza inflata. Moreover, we explored the content of bioactive compounds (glycyrrhizic acid, liquiritin and total flavonoids) in roots of medicinal licorices based on high-performance liquid chromatography. Our results showed that the liquiritin content was not affected by the root depth (0-20cm, 20-40cm and 40-60cm), but was significantly affected by the main effect species (Glycyrrhiza uralensis, Glycyrrhiza inflata, Glycyrrhiza glabra) (P < 0.05), and the content of liquiritin was accountable for the differences in the diversity of endophytic fungal community. Furthermore, distance-based redundancy analysis (db-RDA) showed that soil physicochemical properties (available potassium and ammonium nitrogen), and the root factor (liquiritin and water content) were the main contributing factors to the variations in the overall structure of endophytic fungal community in this study.