This isn't a particularly easy question to answer because it is very broad in scope. So, the answer is: it depends. Are you an armored pikeman in a disciplined tercio facing light cavalry? Or are you a conscript soldier with a spear with shaky looking conscripts to your left and right with heavy armored knights baring down with 20 foot lances leveled in a disciplined charge? Obviously the outcome would be quite different in these scenarios. Here's a good list with descriptions of the most common medieval weapons for reference for the remainder of the post.
I'll try to answer the question as if you are an average campaigner with a regiment that has seen action before, but wouldn't be considered veterans armed with pikes and some halberds in the second rank, facing medium cavalry raised by a petty noble armed with swords and armored chest pieces. In this scenario both combatants are commanded by competent officers, so no one is positioned on the reverse side of a slope with flanks uncovered and no support. We are somewhere around the era of the 30 years war.
Typically, before the handheld firearm equipped infantry era, the center of European armies were comprised of lines of pikeman standing shoulder to shoulder with their weapons leveled towards the enemy (once this was done, it was difficult to go any direction but forward unless you possessed an army of exceptionally well drilled pikeman, which few European armies did - the seasoned fighters were in the cavalry and the artillery). The flanks would consist of cavalry and possibly artillery or arquebusiers if they were available, and would face a similar formation across the field. The typical initial attack would be comprised of the two lines of pikeman marching toward one another at a measured pace so that no gaps in the line appear and then engage in a "push of pikes" in which the more disciplined/most seasoned/larger numbers/higher morale would eventually win and the other side would break and run. While this was going on the flanks would see the cavalry try and run the opposing cavalry off the field, and then turn the flank or rear of the opposing pike line (remember once everyone has their pikes facing one way, it is difficult to disengage, raise the pikes as one unit, turn to face the new threat, level the spears and reengage) which will hurry the breaking and running portion considerably. The cavalry was rightly seen as the decisive arm on the battle field for this reason. At the actual push of pike it is likely that engagement was perfunctory, and showy without being particularly deadly - characterized by "pulses" where each side engages and pushes for a while, and if there's no sign of wavering disengage and pull back slightly to rest for a brief period before going at it again.
So, let's say your army didn't bring much in the way of cavalry, and your opponent did. Lets also say that you're near the flank of the line, but your flank is not exposed. The enemy brought lots of cavalry, and a hot-headed impetuous officer in charge decides to charge before the proper timing at your regiment. Now, let's say your pay is months in arrears, you haven't had a decent meal in days, and your officer is a noble asshole, there's a good chance you and/or your compatriots will say "fuck this," and break formation and run (which is a rout, not a mutiny. A mutiny would be if you refused to follow your officers onto the field in the first place). Contrariwise, if your morale was good, you had trust in your officers and stood your ground in the face of the charge, you would have a very good chance of surviving. Horses, no matter how disciplined, will not willingly impale themselves on outstretched spears, so cavalry relies on its shock and psychological value to break lines of infantry so armed. In the event of a failure to break the line, some cavalrymen might fall forward into the lines if the horses behind crowd them forward (this is where your halberdiers come in handy to dismount the troopers with their hooked weapons and then make short work of them with short swords or daggers carried as sidearms), but the remainder will break off and ride away to regroup. This is another advantage that cavalry possesses: the speed and maneuverability to regroup and recharge the same line repeatedly. Is your morale up to facing down repeated charges? Especially when some of your fellow regiments may have broken and exposed your flanks, or if the enemy has managed to bring forward some artillery to fire in your direction? Maybe you do, but maybe your friends don't. Maybe vice versa.
If you do break and rout then the real danger begins as the victorious army may pursue you and may or may not offer quarter. Most of the real slaughter took place after the pitched battle when the individual soldier could be picked off by cavalrymen as they attempted to flee the field. Hopefully your officers were good enough to impress this point in you so that you relied on your discipline and stood your ground, if so you had a fair to good chance of surviving provided the enemy cavalry was kept away from your flanks and rear.
Hope that has been at least in the vicinity of answering your question.
edit: A few words and some punctuation, and the moderators have asked me to source my post, which sadly I can't quote right now as I'm moving and all my stuff is packed. However, two of the works that most heavily influence my understanding of the mechanics and psychology of hand to hand fighting, and the effects of cavalry in war are:
The Face of Battle: A Study of Agincourt, Waterloo, and the Somme, Ian Kershaw Penguin books 1983
and
On Killing, Lt Col Dave Grossman Little, Brown and Company 1996
I would also like to source Mike Duncan's "Revolutions" podcast for some of the narrative I borrowed regarding English Civil War (contemporary to the 30 Years' War) era battles.
While we wait for someone qualified to respond, here's some related reading from previous related questions:
Psychology of front lines: https://www.reddit.com/r/AskHistorians/comments/1107o8/in_medieval_battles_what_was_the_psychology_of/
Medieval pike formation warfare: https://www.reddit.com/r/AskHistorians/comments/v8dql/did_people_really_throw_themselves_on_spears_and/c52a2vy
Why is calvary so deadly?: https://www.reddit.com/r/AskHistorians/comments/21981k/why_was_cavalry_so_deadly/cgbhdew?context=3
Survivability of knights: https://www.reddit.com/r/AskHistorians/comments/217308/how_did_medieval_knights_survive_enough_battles/
To tack on a question, how likely is it to even be in a situation to hold against a cavalry charge? What I know about medieval warfare and horses tends to point towards a frontal charge by cavalry quite unlikely.