Insurgents were using the school as a transit camp until yesterday's attack, an army statement said.
Boko Haram, a nickname which means "Western education is forbidden" has attacked many schools that have closed, been burned down or been abandoned in much of northeastern Borno state.
The UN Children's Fund says more than 300 schools have been destroyed in an area where fewer than 30 per cent of children are ever educated.
Nigeria's new President Muhammadu Buhari last week told NDTV, the New Delhi station, that negotiations to free nearly 300 girls kidnapped from a school last year in Chibok town have stalled because authorities have been unable to identify "credible" Boko Haram leaders to talk to.
The UN Children's Fund says 10.5 million children are out of school in Nigeria the highest number in the world and that only half of children among 2.3 million refugees from the uprising are going to school in camps.