Yuxian was a Manchu whose family was registered in the Bordered Yellow Banner, one of the Eight Banners. His father served in minor government positions in Guangdong. Instead of passing the civil service examination, Yuxian purchased a degree that qualified him to serve as an official. Although he bought a position of prefect in Shandong province in 1879, only in 1889 did he start to serve in Caozhou, an unruly prefecture in southwestern Shandong that was prone to flooding and plagued by bandits. The departure of local troops for the front of the Sino–Japanese War in 1894 led to a sharp increase in banditry in the area. Yuxian managed to keep bandits under control with the help of local self-defense groups like the newly founded Big Swords Society. Having developed a reputation for efficient administration, in 1895 he was promoted to the rank of circuit intendant ("daotai" ), with several prefectures under his jurisdiction.