Disclosed are pyrimidine or pyridine compounds, pharmaceutically acceptable salts, stereoisomers, prodrugs and solvates thereof, preparation method therefor and pharmaceutical compositions and pharmaceutical uses thereof. The compounds can inhibit the variants of EGFR (Epidermis Growth Factor Receptor) proteinases, and therefore can inhibit the growth of varieties of tumor cells effectively. The compounds can be used to manufacture anti-tumor drugs which can be used to treat, combined-treat or prevent many different cancers. The compounds can get over the drug resistance deduced by the present first-generation EGFR inhibitors such as gefitinib, erlotinib and so on. Particularly, the compounds can be used to manufacture drugs for treating or preventing diseases, disturbances, disorders or conditions mediated by epidermis growth factor receptor variants (such as L858R activating mutants, Exon19 absence activating mutants and T790M antibody mutants).