The treatment of Staphylococcus aureus infections is impeded by the prevalence of MRSA and the formation of persisters and biofilms. Previously, we identified two celecoxib derivatives, Cpd36 and Cpd46, to eradicate MRSA and other staphylococci. Through whole-genome resequencing, we obtained several lines of evidence that these compounds might act by targeting the membrane protein translocase YidC2. Our data showed that ectopic expression of YidC2 in S. aureus decreased the bacterial susceptibility to Cpd36 and Cpd46, and that the YidC2-mediated tolerance to environmental stresses was suppressed by both compounds. Moreover, the membrane translocation of ATP synthase subunit c, a substrate of YidC2, was blocked by Cpd46, leading to a reduction in bacterial ATP production. Furthermore, we found that the thermal stability of bacterial YidC2 was enhanced, and introducing point mutations into the substrate-interacting cavity of YidC2 had a dramatic effect on Cpd36 binding via surface plasmon resonance assays. Finally, we demonstrated that these YidC2 inhibitors could effectively eradicate MRSA persisters and biofilms. Our findings highlight the potential of impeding YidC2-mediated translocation of membrane proteins as a new strategy for the treatment of bacterial infections.