Tyler O'Neill and Dexter Fowler added solo homers for St. Louis in the first game of an unprecedented 60-game season shortened due to the coronavirus pandemic. No fans were allowed into Busch Stadium, although some did watch from a rooftop across the street.
Flaherty, who went 7-2 with an 0.91 ERA over his final 15 regular season starts last year, did not give up a run until Jacob Stallings hit two-out, two-run single just under the glove of first baseman Paul Goldschmidt in the seventh.
''Jack is Jack - he's a bulldog,'' O'Neill said. ''He's going to give us his best effort.''
St. Louis, which won the NL Central with a 91-71 mark last year, built up a 3-0 cushion on homers by O'Neill in the third and Fowler in the fifth.
Yadier Molina added a run-scoring hit in the sixth.
Pittsburgh climbed within 3-2 before DeJong unloaded against Richard Rodriguez in the eighth.
Kwang Hyun Kim allowed two runs before retiring three successive hitters to get the save in his major league debut. The 32-year-old Kim pitched 12 years in Korea before coming to the U.S. this season.
Flaherty gave up two earned runs on six hits over seven innings. He struck out six and did not walk a batter.
''I saw a guy that was super-efficient,'' St. Louis manager Mike Shildt said. ''He was in control of everything he was doing. In the seventh (inning), he was still making quality pitches.''
Flaherty, who finished fourth in the NL Cy Young voting last season, retired nine consecutive batters on two different occasions. The 24-year-old is the youngest St. Louis pitcher to start a season opener since Joe Magrane on April 3, 1989.
''The juices were flowing, it was opening day,'' Flaherty said. ''It was just about trying to get some quick outs. It was fun to see all the guys come out and play a tough ballgame.''
Pittsburgh starter Joe Musgrove allowed three runs and five hits over 5 2/3 innings. He fanned seven and walked three.
The Pirates, under first-year manager Derek Shelton, fell to 71-63 in season openers.
''I thought we played well,'' Shelton said. ''We gave up a couple home runs and that ended up being the outcome of the game.''
Goldschmidt and Kolten Wong added two hits each for the Cardinals.
''The emphasis is definitely there for these early wins,'' O'Neill said. ''Show the league we're here for business.''
Prior to the game, Pirates outfielder Jarrod Dyson took a knee during the national anthem to protest social injustice. He was joined by Shelton, who moved from the end the line to stand by his player.
Molina made his 16th straight opening day start at catcher. He is second in franchise history behind Stan Musial, who started in 18 consecutive curtain raisers.
Pirates: OF/INF JT Riddle is on the 10-day injured list with a strained abdominal muscle. ... OF Gregory Polanco is out after testing positive for the coronavirus on July 17.
Cardinals: INF/OF Brad Miller is on the 10-day injured list with right ankle bursitis.
Pittsburgh RHP Trevor Williams will face RHP Adam Wainwright in the second game of a three-game series on Saturday. Williams was 7-9 with a 5.38 ERA in 26 starts last season. Wainwright is 16-8 with 4.24 ERA in 42 career appearances against the Pirates.
More AP MLB: https://apnews.com/MLB and https://twitter.com/AP-Sports
Copyright 2022 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.