I've only seen them getting mentioned in mythologies being greek/roman.But were they ever used as a weapon by foot soldiers?
They were used. I discussed this and gave some examples in https://www.reddit.com/r/AskHistorians/comments/blckca/why_were_trident_and_pitchforklike_weapons_never/
To add to what I wrote there, the trident appears in Greek and Roman mythology in the hands of Poseidon/Neptune, in the form of a barbed fishing spear:
which is appropriate for a sea god. The gladiatorial retiarus, named after his net rather than his trident, follows this fishing theme:
Barbed weapons (other than single use items such as arrows and javelins) are typically for hunting rather than warfare, since it is usually considered undesirable to disarm oneself by hitting an enemy and getting the weapon stuck (but getting the weapon stuck can be a good thing for javelins, since it makes it harder for them to be used by the enemy). While fishing is the classic use for barbed multi-pronged spears, they do appear in other hunting contexts, too: