Mammillaria hernandezii is a species of cacti in the tribe Cacteae. It is native to Mexico where it has a disjointed distribution in a small area of upland tropical pine scrub. There are estimated to be fewer than 500 plants in the wild and is classified as endangered.