Police were called out to Doncaster marketplace to reports of a man armed with three knives terrified shoppers feared was going to 'start stabbing people,' a court heard.
Sheffield Crown Court was told how prior to the incident taking place on June 24 this year, David Danks had bought a set of five craft knives from Poundworld.
Danks, aged 29, kept three of the knives and threw the other two away.
Beverley Tait, prosecuting, said: "Officers were called to reports of a man there with a knife that was going to start stabbing people.
"As they arrived he pulled from his pocket one of the knives and put it down on a wall and then produced another two knives.
"He explained that he was being followed and that was the reason he had them.
"After arrest he said he need to see a psychologist and that he suffered from mental difficulties."
Ms Tait told the court that Danks had 43 previous convictions from 69 offences, seven of which involved the possession of a weapon in a public place.
Danks pleaded guilty to three counts of possessing a bladed article in a public place, relating to the June incident, at an earlier hearing.
Defending, Andrew Smith, told the court that Danks offending was borne out of his mental health problems, and that he had traveled to Doncaster from Birmingham.
Mr Smith said: "He doesn't even known anyone in Doncaster. He doesn't even know how he got there. He thinks he got a train there."
He added: "He came to Doncaster, and in effect, got himself arrested. It was a cry for help."
Mr Smith told the court that Danks did not have a safe home to go to should be released, leaving him free to return to Birmingham.
Sentencing Danks to eight-months in prison, Judge David Dixon said: "This is the eighth occasion you have appeared before the courts for a bladed article offence.
He added: "The purpose of this sentence is to ensure that your mental health problems can be treated and to give Birmingham authorities enough time to find you somewhere safe to live, and I'm not sure that could be achieved with a lesser sentence.