Mayr was born into the family of a lawyer, Ignaz Mayr, and his wife, née Rosalie Holzer, in Vienna. After completing classical high school and studying at the faculty of philosophy, Mayr began studying medicine in Vienna. From 1851, he was a member of the Vienna Botanical and Zoological Society (Zoologisch-Botanische Gesellschaft). He was a doctor of medicine in 1856, then taught natural sciences and chemistry in secondary schools in
Pest, but he lost his post in 1861, because of the Magyarization laws which prohibited teaching in German in Hungarian secondary schools. Mayr was passionate about entomology and in particular about the Hymenoptera, and specialised in the
systematics of ants. He donated one of his collections of hymenopterans, bringing together 1,350 species represented by around 5,500 specimens, to the
Natural History Museum, Vienna, in 1896. Another collection of 2,180 species of ants, and other collections of insects was bequeathed by him in his will to the Vienna Botanical and Zoological Society, but they later sold it to the museum, not having the facilities to maintain it. Between 1862 and 1901, he described 58
genera of ants (including
Acromyrmex,
Anochetus,
Aphaenogaster,
Camponotus,
Formicoxenus,
Leptothorax,
Monomorium, and
Tetramorium) and over 500 new species of ants. He also described unique collections of fossil ants preserved in
Baltic amber (1868), ants from Tibet brought back by the expeditions of
Nikolay Przhevalsky, and ants from Turkestan collected by explorer
Alexei Fedchenko. He was responsible for writing the zoological part concerning ants in the travel report of the
Austrian Imperial Novara expedition that circumnavigated the world between 1857 and 1859. He died in Vienna. == Works ==