The team announced the deal Wednesday.
Mayers says he was looking to join a team that gave him the best chance to win. San Jose made it to the Western Conference final last season before losing to eventual champion Chicago.
Mayers split time last season with Toronto and Calgary. He had three goals, 11 assists and 131 penalty minutes in 71 games.
Mayers has played 737 career games with St. Louis, Toronto and Calgary. He has 81 goals, 107 assists and 969 penalty minutes.
The Sharks have also re-signed minor league center Steven Zalewski to a one-year contract.