Mayr grew up in Gröbming as the son of a butcher and innkeeper. From 1887 he attended the Imperial and Royal State Grammar School in Graz, graduating with distinction in 1895. He then studied medicine in Graz and received his doctorate summa cum laude in May 1901.
During several internships at the spa and hydrotherapy institute of Sankt Radegund near Graz (1899–1903), he treated patients with severe constipation manually. From these observations he developed the first approaches to his own diagnosis and therapy of the digestive tract.
In 1903 he took over the management of the Johannisbrunn hydrotherapy institute near Troppau. Between 1903 and 1906 he made study trips to Paris, Nancy, Dresden, Berlin and London, where he studied pathology, psychotherapy and dietetics. In the museums of Naples and Rome he studied the physique of ancient statues and paintings and incorporated his observations on posture and constitution into his concept of diagnosis and treatment.
From 1906 Mayr treated patients in the spa town of Karlsbad in summer and in Vienna in winter. In 1915 he conducted his first own fasting cure.