When you encounter a bear never run because running may cause the bear to run after you and you won't be able to outrun a bear.
When you see a bear you should remain calm and back away slowly and the bear will usually leave you alone and go the other way.
If a bear does try to attack you or come towards you then usually laying on the ground and playing dead will usually stop the bear from attacking you as they no longer see you as a threat.
Having bear mace on hand is also a good idea just in case the bear tries to attack you.
But most times bears will leave humans alone as long as they do not see you as a threat to them.
Running will make the bear more likely to run after you so just remain calm and back away slowly or walk away slowly when encountering a bear as running could cause more harm to you.