I am an outdoor guide (backpacking, climbing, etc.) working mainly in black bear country. The others are correct. Bear spray is by far your best option. Next up would be a pistol. A knife in a bear fight would be a last ditch type of thing, and probably just as likely to end up stuck in you. Honestly, your best defense against a bear is to be smart. Don't put anything that might have any kind of odor in your tent. No food, toothpaste, deodorant, medicine, food wrappers, etc. All of that needs to be hung in a bear bag. Practice hanging a bear bag before you go. It needs to be at least 10ft off the ground and 4ft from any tree or branch. Be careful not to spill food on your clothing, and if you do, don't sleep in it. Don't cook or eat near your tent. While hiking, a bell or just talking will help keep you from surprising a bear. Don't approach any bear, and certainly don't feed them. Don't turn your back on a bear, or run from them. Just back up slowly. If one follows you or stares you down, make yourself look big. Wave your arms, throw rocks, and yell. If you do get mauled, FIGHT BACK!!! Do not listen to people that tell you to play dead! That is the strategy with brown bears. With black bears, it's recommended that you fight back. Stay far away from mothers with cubs.
I will tell you though, in 20 years of backpacking and guiding, I have only had one bad experience with a black bear, and it was because he already had someone's food. Other than that, seeing bears in the wild is a cool thing, not something to be scared of. They are generally skittish, and will bolt as soon as you yell or throw a rock their way. Remember, they live in the wild. There is no bear hospital. To them, a fight means possibly getting hurt, which could be a death sentence. They will generally only fight if they feel like they have to, or if they're starving. Be smart, you'll be fine.