If you can't run away (maybe your attacker is a track star or something) and can't get close enough to wrestle the knife away without getting hurt, here's something that might help.

Whenever someone tries to hit you, you move and block and then strike. Remember: "move, block, strike". For instance, if someone in front of you tries to stab you, you move your right foot (if you're right handed) behind your left foot. While you do this, rotate your left foot (but don't move it anywhere else). When you're done, you should be facing right without your feet being twisted; your feet should be close to facing right also. You should also be to the left of where you were when you started.

At the same time you are moving out of the way, you should use your right hand to grab the arm that's thrusting the knife at you. Grab below the elbow; the closer to the hand you get without hitting the knife, the easier it'll be to control the arm. Keep your right arm almost fully extended (without locking your elbow out).

Then take a step sideways toward your attacker with your left foot. Your feet should be spread apart a little more, but you should still be facing right. This moves you closer to your attacker, so you can do damage more easily.

Then, do whatever will cause the most pain to your attacker. It should be the kind of pain that causes them to forget they're holding a knife and it should be a method that causes this to happen quickly. Once they are in sufficient pain, you can do a few things.

Get them to drop the knife. If they look like they really want to stop fighting you, you can demand that they drop it. Or, you can break their elbow by striking the outside of it sharply with the heel of your left hand. Or, you can grab the handle of the knife like you would hold it, and take it from them.

Make it really painful for them to run and then run away. You should kick or stomp them in the shins or kneecaps and, if you have time, do something to cause nausea and weakness, like kicking them in the testicles sharply. This will make it extremely painful to run and also cause them not to be able to breathe properly.

Knock them out or knock them senseless. Then, still holding on to the knife arm with your right hand, take the knife by its handle with your left. If that's too awkward, grab the arm with your left hand before letting go with your right hand and grab the knife with your right hand.

Kill them with whatever weapon you have. If you have the weapon in your left hand, use it immediately after moving, blocking, and moving toward them. If it's readily available, cause them pain so that they stop paying attention to you and quickly get it out and use it. If it's not readily available, forget it.

Whatever you do, hold the person's knife arm at all times and keep your holding arm almost fully extended at all times (without locking your elbow out). If you want to do something that would be awkward or impossible to do while grabbing the person's arm and keeping your arm extended, it's best not to do it.

It's best to practice this with a friend until it becomes second nature. If you do, do not use anything that will hurt if you get jabbed by it. Don't use sharp knives, dull knives, sticks, pipes, etc. If you can't find something (for example, a very bendy fake rubber knife or a piece of foam), don't use anything; pretend your friend has a knife. Also, don't actually hit your friend (except their arm when you grab it). Also, vary the attacks. Your friend shouldn't just try to "stab" you in the neck; they should try all sorts of attacks, like slashing your gut or stabbing your arms, or going berserk and slashing everywhere; they should try different ways of holding the "knife", too, especially with the blade pointing down (so that you can learn to grab the arm without hitting the blade).