On the night the Yankees and Diamondbacks honored Jackie Robinson by each wearing No. 42, two Yankees with deep ties to the former Dodgers star carried the hosts to victory.

Mariano Rivera, the last player to wear No. 42, and Robinson Cano, who was named after Robinson, helped the Yankees cop their sixth win in seven games with a 4-2 victory in front of 34,107 at Yankee Stadium.

“I told him he is the right guy to have 42,” Cano said of Rivera, who worked a perfect ninth for his third save in as many attempts.

Cano, who has carried the Yankees with Alex Rodriguez, Derek Jeter, Mark Teixeira and Curtis Granderson on the disabled list, crushed a three-run homer in the fourth inning off Brandon McCarthy that landed in the right-center field bleachers and erased a 2-0 deficit.

“He has an easy way to get it done,” Rivera said of Cano, who is hitting .500 (13-for-26) with 11 RBIs in the past six games.

Cano, a native of the Dominican Republic, enjoyed the occasion.

“He changed the game of baseball,” he said of Robinson. “If it wasn’t for him, we wouldn’t be here. It’s one of the fun days in the big leagues.”

If it were not for Cano, the Yankees would not have won six or seven or be 7-5 after opening the season 1-4.

“When Robbie got it going, we got it going as a team,” manager Joe Girardi said. “When he got hot our offense took off.”

Thanks to solid relief work by Boone Logan, Joba Chamberlain, David Robertson and Rivera, Cano’s homer and Eduardo Nunez’s sacrifice fly in the seventh inning were enough.

“Everybody from Logan to Robertson did their job,” said Rivera, who worked a perfect final frame using a cut fastball clocked between 89 and 91 mph. “We have been pitching better, and we want to keep it going.’’