A compound of formula: or a tautomer, mesomer, racemate, enantiomer, diastereomer, or mixture thereof, or a pharmaceutically acceptable salt thereof, wherein: ring A is selected from the group consisting of heterocyclyl and cycloalkyl; each R 1 is identical or different and each is independently selected from the group consisting of hydrogen, halogen, alkyl, haloalkyl, alkoxy, haloalkoxy, amino, nitro, hydroxy, cyano, cycloalkyl, heterocyclyl, aryl, heteroaryl, -OR 6, -C R 6, -C OR 6, - S m R 6, -S m NR 7 R 8 and -(CH 2) x R a, wherein the alkyl, haloalkyl, heterocyclyl, aryl and heteroaryl are each independently and optionally substituted by one or more groups selected from the group consisting of alkyl, haloalkyl, halogen, amino, nitro, cyano, hydroxy, alkoxy, haloalkoxy, hydroxyalkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl; R a is selected from the group consisting of halogen, cycloalkyl, heterocyclyl and -NR 7 R 8, wherein the cycloalkyl and heterocyclyl are each independently and optionally substituted by one or more groups selected from the group consisting of alkyl, haloalkyl, halogen, amino, nitro, cyano, hydroxy, alkoxy, haloalkoxy, hydroxyalkyl, cycloalkyl, heterocyclyl, aryl, and heteroaryl; R 2 is hydrogen or alkyl, wherein the alkyl is optionally substituted by one or more groups selected from the group consisting of halogen, hydroxy, cyano, cycloalkyl and heterocyclyl; R 3 is selected from the group consisting of hydrogen, alkyl, halogen, cyano, alkoxy and haloalkyl; each R 4 is identical or different and each is independently selected from the group consisting of hydrogen, alkyl, haloalkyl, hydroxy, amino, alkoxy, haloalkoxy, cycloalkyl, heterocyclyl, aryl, heteroaryl, -OR 6, -C R 6, -C OR 6, -S m R 6, -S m NR 7 R 8 and -NR 7 R 8; each R 5 is identical or different and each is independently selected from the group consisting of hydrogen, alkyl, oxo, halogen, haloalkyl, hydroxy, amino, alkoxy, haloalkoxy, cycloalkyl, heterocyclyl, aryl, heteroaryl, -OR 6, -C R 6, -C OR 6, -S m R 6, -S m NR 7 R 8 and -NR 7 R 8; R 6 is selected from the group consisting of hydrogen, alkyl, haloalkyl, alkoxy, hydroxyalkyl, hydroxy, amino, cycloalkyl, heterocyclyl, aryl and heteroaryl; R 7 and R 8 are identical or different and each is independently selected from the group consisting of hydrogen, alkyl, alkoxy, hydroxyalkyl, hydroxy, amino, alkoxycarbonyl, cycloalkyl, heterocyclyl, aryl and heteroaryl, wherein the alkyl, amino, cycloalkyl, heterocyclyl, aryl and heteroaryl are each independently and optionally substituted by one or more groups selected from the group consisting of alkyl, halogen, hydroxy, amino, alkoxycarbonyl, nitro, cyano, alkoxy, hydroxyalkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl; m is 0, 1 or 2; n is 0, 1, 2 or 3; p is 0, 1, 2, 3, 4 or 5; q is 0, 1 or 2; and x is 0, 1, 2 or 3. ring A is selected from the group consisting of heterocyclyl and cycloalkyl; each R 1 is identical or different and each is independently selected from the group consisting of hydrogen, halogen, alkyl, haloalkyl, alkoxy, haloalkoxy, amino, nitro, hydroxy, cyano, cycloalkyl, heterocyclyl, aryl, heteroaryl, -OR 6, -C R 6, -C OR 6, - S m R 6, -S m NR 7 R 8 and -(CH 2) x R a, wherein the alkyl, haloalkyl, heterocyclyl, aryl and heteroaryl are each independently and optionally substituted by one or more groups selected from the group consisting of alkyl, haloalkyl, halogen, amino, nitro, cyano, hydroxy, alkoxy, haloalkoxy, hydroxyalkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl; R a is selected from the group consisting of halogen, cycloalkyl, heterocyclyl and -NR 7 R 8, wherein the cycloalkyl and heterocyclyl are each independently and optionally substituted by one or more groups selected from the group consisting of alkyl, haloalkyl, halogen, amino, nitro, cyano, hydroxy, alkoxy, haloalkoxy, hydroxyalkyl, cycloalkyl, heterocyclyl, aryl, and heteroaryl; R 2 is hydrogen or alkyl, wherein the alkyl is optionally substituted by one or more groups selected from the group consisting of halogen, hydroxy, cyano, cycloalkyl and heterocyclyl; R 3 is selected from the group consisting of hydrogen, alkyl, halogen, cyano, alkoxy and haloalkyl; each R 4 is identical or different and each is independently selected from the group consisting of hydrogen, alkyl, haloalkyl, hydroxy, amino, alkoxy, haloalkoxy, cycloalkyl, heterocyclyl, aryl, heteroaryl, -OR 6, -C R 6, -C OR 6, -S m R 6, -S m NR 7 R 8 and -NR 7 R 8; each R 5 is identical or different and each is independently selected from the group consisting of hydrogen, alkyl, oxo, halogen, haloalkyl, hydroxy, amino, alkoxy, haloalkoxy, cycloalkyl, heterocyclyl, aryl, heteroaryl, -OR 6, -C R 6, -C OR 6, -S m R 6, -S m NR 7 R 8 and -NR 7 R 8; R 6 is selected from the group consisting of hydrogen, alkyl, haloalkyl, alkoxy, hydroxyalkyl, hydroxy, amino, cycloalkyl, heterocyclyl, aryl and heteroaryl; R 7 and R 8 are identical or different and each is independently selected from the group consisting of hydrogen, alkyl, alkoxy, hydroxyalkyl, hydroxy, amino, alkoxycarbonyl, cycloalkyl, heterocyclyl, aryl and heteroaryl, wherein the alkyl, amino, cycloalkyl, heterocyclyl, aryl and heteroaryl are each independently and optionally substituted by one or more groups selected from the group consisting of alkyl, halogen, hydroxy, amino, alkoxycarbonyl, nitro, cyano, alkoxy, hydroxyalkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl; m is 0, 1 or 2; n is 0, 1, 2 or 3; p is 0, 1, 2, 3, 4 or 5; q is 0, 1 or 2; and x is 0, 1, 2 or 3.