To investigate the mechanical properties of cement mortar in sodium sulfate and sodium chloride solutions, uniaxial compression test and ultrasonic test were performed. Test results show that the relative dynamic elastic modulus, the mass variation, and the compressive strength of cement mortar increase first, and then decrease with increasing erosion time in sodium sulfate and sodium chloride solutions. The relative dynamic elastic moduli and the compressive strengths of cement mortars with water/cement ratios of 0.55 and 0.65 in sodium sulfate solution are lower than those in sodium chloride solution with the same concentration at the 420th day of immersion. The compressive strength of cement mortar with water/cement ratio of 0.65 is more sensitive to strain rate than that with water/cement ratio of 0.55. In addition, the strain-rate sensitivity of compressive strength of cement mortar will increase under attacks of sodium sulfate or sodium chloride solution.