He is the first opposition figure to win a presidential election in Nigeria since independence in 1960.
"I belong to everybody and I belong to nobody", he told cheering crowds at the inauguration in the capital, Abuja.
He vowed to tackle "head on" the issues of corruption and the insurgency from militant Islamist group Boko Haram.
"This government will do all it can to rescue them alive," he said.
Mr Buhari said the Nigerian economy was "in deep trouble", identifying "insecurity, pervasive corruption... and seemingly impossible fuel and power shortages" as key concerns.
The country's power supply crisis was "a national shame", he said, which had brought "darkness, frustration, misery, and resignation" to Nigerians. in 2015.