The growth of endophytic bacteria is influenced by the host plant and their secondary metabolites and activities. In this study, P-NA14 and D-HT207 were isolated from potato tuber and dendrobium stem respectively. They were both identified as Priestia megaterium. The antimicrobial activities and metabolomic of both strains were explored. For antimicrobial activities, results showed that strain P-NA14 exhibited a better inhibition effect on the pathogen of dendrobium, while strain D-HT207 exhibited a better inhibition effect on the pathogen of potato. The supernatant of strain P-NA14 showed an inhibition effect only on Staphylococcus aureus, while the sediment of strain D-HT207 showed an inhibition effect only on Escherichia coli. For metabolomic analysis, the content of L-phenylalanine in strain P-NA14 was higher than D-HT207, and several key downstream metabolites of L-phenylalanine were associated with inhibition of S_aureus including tyrosine, capsaicin, etc. Therefore, we speculated that the different antimicrobial activities between strain P-NA14 and strain D-HT207 were possibly related to the content of L-phenylalanine and its metabolites. This study provided a preliminary exploration of the fact why different activities appeared on the strains that were identified as the same species but isolated from different hosts at the metabolomic level.