Trincao opened the scoring from a pass by Ilaix Moriba – both players were making their first La Liga starts – and Messi doubled the lead via the inside of the post from outside the box.
Luis Rioja gave struggling Alaves hope.
Trincao scored again after Messi’s shot was saved and then the Argentine netted an excellent 25-yard strike before Junior Firpo’s close-range fifth.
Messi and Trincao’s doubles both came on landmarks days.
Messi, 33, was making his 505th La Liga appearance, equalling Xavi’s club record. Trincao, 21, was making the first La Liga start of his career – although he has been a regular off the bench and in cups this season.
Both players had goals disallowed for offside, with Messi’s ruled out by the video assistant referee for an exceptionally close call on Antoine Griezmann.
Barcelona move up to second with the victory, albeit eight points behind leaders Atletico Madrid. (Courtesy BBC)