New loan signing Joao Cancelo was in the starting lineup, 24 hours after joining the team from Manchester City.
The Bavarians' last win before the World Cup break was against Schalke 04 since then it has been back-to-back draws usually with a 1-1 scoreline.
Eric Maxim Choupo-Moting and Jamal Musiala scored for Bayern in the first half, before Leroy Sane added a third goal two minutes before the break. Joshua Kimmich hit the woodwork with a free kick, but Bayern kept up their intensity level throughout the half.
Mainz found more space in the second half but could not find a goal. Coach Bo Svensson was sent off for dissent and a defender was given a red card for a double booking.
Despite this, Bayern continued to play at a high level and Alphonso Davies scored with a header in the 83rd minute.
Holders RB Leipzig also moved on to the next round with a 3-1 victory over Hoffenheim.
Bayern will face Paris Saint-Germain in the Champions League Round of 16 in two weeks and will look to continue their winning streak in the German Cup.