Born in Charlestown, Massachusetts, Wainwright was commissioned in the United States Navy on 11 May 1831. Between 1841 and 1857, Wainwright served in the Coast Survey and on the Navy's Home Station. He cruised in Merrimack on special service from 1857 to 1860.
Following the outbreak of the Civil War, Wainwright commanded Hartford, flagship of Admiral David G. Farragut's West Gulf Blockading Squadron. During the passage of forts below New Orleans, Louisiana on the night of 24 and 25 April 1861, he performed gallant service in extinguishing a fire on Hartford while continuing the bombardment of the forts. Commended by Admiral Farragut for his actions, Wainwright later participated in the squadron's operations below Vicksburg until taken ill with fever.