Kirby Yates escaped a bases-loaded threat in the ninth to save San Diego's third straight win.
Bauer (10-10) recovered from one of the worst outings of his career by giving up three runs and fanning 11 in seven innings. San Diego scored one of the runs on José Peraza's fielding error in left field. Bauer gave up a career-high nine runs in 4 1/3 innings of a 17-7 loss at Washington on Wednesday.
Machado had an RBI single in the first inning, leaving him 10-for-15 in his career off Bauer with four homers, two doubles and six RBIs. Mejía connected in the fourth, his slicing fly ball deflecting off the foul pole in right to put San Diego ahead to stay. San Diego is three homers shy of the club record of 189 from 2017.
Left-hander Eric Lauer gave up Freddy Galvis' homer in four innings on a humid, 94-degree night. Luis Perdomo (2-3) fanned four in two innings.
Yates allowed three hits, including Josh VanMeter's RBI single, in the ninth and loaded the bases with two outs. He fanned Eugenio Suarez for his NL-leading 36th save in 39 chances.
The Padres had a run-saving play in the second inning. Left fielder Josh Naylor threw Suarez out at the plate as he tried to score from second on Peraza's single.
José Iglesias singled and extended his hitting streak to 14 games, the longest by a Reds player since Joey Votto's 17-game streak in 2017. Iglesias' career high is an 18-game streak in 2013.
Aristides Aquino went 0 for 3 with a pair of strikeouts and was hit by a pitch. He homered 11 times in his first 17 games, a major league record for a rookie.
COUNTING DOWN
Reds left-handed reliever Amir Garrett served the seventh game of his eight-game suspension for precipitating a brawl against the Pirates on July 31.
TRAINER'S ROOM
Padres: Naylor was back in left field a day after he swung at a pitch and felt discomfort in his right side, forcing him to leave the game.
Reds: Outfielder Jesse Winker was out of the lineup for the fifth straight game because of upper back spasms. Center fielder Nick Senzel was a late scratch with a sore left elbow that was hit by a pitch on Sunday.
UP NEXT
Padres: Cal Quantrill (6-3, 3.23 ERA) is 4-1 with a 1.31 ERA since the All-Star break that ranks third-best in the majors.
Reds: Sonny Gray (8-6, 2.98) is 5-1 with a 1.59 ERA in his last nine starts, including eight quality starts. He's been the victim of a blown save three times.