According to German police, three of the victims were severely injured in the Monday night incident, which happened in the Heidingsfeld region of the city of Wurzburg.
At least 20 injuries were initially reported in the attack, but later it was announced that some 14 people were treated for trauma on the scene.
A few hours after the incident, Bavarian Interior Minister Joachim Herrmann announced that suspect was a 17-year-old Afghan asylum seeker who had taken up residence in the nearby town of Ochsenfurt.
Police said the assailant was shot dead after fleeing the train.
Herrmann noted that the authorities are currently investigating reports that the attacker yelled out "an exclamation" before the incident. German media quoted some witnesses as saying that he shouted "Allahu akbar" before the attack.
In May, a man was reported as making a similar exclamation before stabbing a person to death and wounding three others at a railway station in Munich.
The incident sparked fears over terrorist attacks on the German soil.
The culprit was later sent to a psychiatric hospital and police said he had no ties to the Takfiri terrorism, Press TV reported.
219