Plants adapt to metal stress by modifying their metabolism including the production of secondary metabolites in plant tissues. Such changes may impact the diversity and functions of plant associated microbial communities. Our study aimed to evaluate the influence of metals on the secondary metabolism of plants and the indirect impact on rhizosphere bacterial communities. We then compared the secondary metabolites of the hyperaccumulator Pteris vittata L. collected from a contaminated mining site to a non-contaminated site in Vietnam and identified the discriminant metabolites. Our data showed a significant increase in chlorogenic acid derivatives and A-type procyanidin in plant roots at the contaminated site. We hypothesized that the intensive production of these compounds could be part of the antioxidant defense mechanism in response to metals. In parallel, the structure and diversity of bulk soil and rhizosphere communities was studied using high-throughput sequencing. The results showed strong differences in bacterial composition, characterized by the dominance of Proteobacteria and Nitrospira in the contaminated bulk soil, and the enrichment of some potential human pathogens, i.e., Acinetobacter, Mycobacterium, and Cupriavidus in P. vittata's rhizosphere at the mining site. Overall, metal pollution modified the production of P. vittata secondary metabolites and altered the diversity and structure of bacterial communities. Further investigations are needed to understand whether the plant recruits specific bacteria to adapt to metal stress.