Born to missionary parents in Ceylon, Mayor entered St John's in 1844, graduated third classic in 1848, and became a Fellow in 1849. For four years he was a master at Marlborough College, during which time he prepared the work on which his scholarly reputation rests, his edition of Juvenal's Satires. Unhappy at Marlborough, he returned to St John's in 1853 and remained there for the rest of his life. Here he devoted himself to his literary, antiquarian and classical interests, and in particular to the study of Cambridge history. He served as University Librarian from 1864 to 1866, and as Professor of Latin from 1872 until his death.
Mayor amassed an enormous library which was originally stored in his College rooms, and later transferred to a small house for its accommodation. When sold in Cambridge after his death it totalled 18,000 volumes. His annotated volumes of Juvenal and Seneca were among the books presented to the College after his death, but he appears to have given generously to the Library throughout his life, and over 1,000 items in the Library include a book label bearing his name. These are mainly from the 18th and 19th centuries, and include numerous classical works and items concerned with the history of the University, as well as more random items such as a set of eight volumes of a "very curious collection of works published, and privately printed tracts & brochures circulated during the French Revolution" put together by Captain J.A. Long (K.13.22-29). There are earlier items of interest, such as a finely bound copy of Hesychius's Lexikon (1521) with an inscription from John Cheke to Roger Ascham, and a first edition of Ascham's The scholemaster (1570).
The volumes given by Mayor generally bear a book label and, less often, his bookplate.