The 30-year-old former Peterborough and Torquay keeper has spent the last two seasons with the Stags' League Two rivals Exeter before being released.
"The lad is an experienced goalkeeper who has a real burning desire to again play Championship football," Stags boss Steve Evans said.
"I am delighted that Bobby has joined us, considering he had a few options."
The length of Olejnik's deal has not been revealed.
The former Austria Under-21 international, who has also played for Scunthorpe and York City, played in both legs of the League Two play-off semi-finals last season, but was on the bench for the final as the Grecians lost to Blackpool at Wembley.
He will compete for the number one goalkeeping position with another recent signing, Conrad Logan.
Find all the latest football transfers on our dedicated page.
Mansfield Town have made their 12th signing of the summer after agreeing a deal for goalkeeper Bobby Olejnik.