An "active shooter" was encountered on the base on Friday morning, according to the Escambia County sheriff's office.
A few minutes later, the shooter was dead, officials said.
A sheriff's deputy fatally shot the shooter in a classroom on the base, Sheriff David Morgan said at a news conference on Friday morning. He declined to share any details about the suspected shooter's identity.
"Walking through the crime scene was like being on the set of a movie," Morgan said.
Eight people were being treated at Baptist Hospital, hospital spokeswoman Kathy Bowers said.
US President Donald Trump had been briefed and was monitoring the situation, a White House spokesman said.
On Wednesday, a sailor shot three civilians at the historic Pearl Harbor military base in Hawaii, killing two of them before taking his own life.
The Pensacola base, which is near Florida's border with Alabama, is a major training site for the Navy and home to its aerobatic flight demonstration squadron, the Blue Angels. The base employs more than about 16,000 military and 7,400 civilian personnel, according to the base's website.