Andile Phehlukwayo claiming 4 wickets to seal the victory.
Imrul was the Tigers' top-scorer with a 68 while Mushfiq, who hit a century in the first ODI, hit 60.
Amla again impressed with a measured 85, but he took on the familiar role of second fiddle as De Villiers - batting for the first time in any worldwide format since June due to his management of his global fixtures - stole the show with a stunning 176.
De Villiers smashed his highest ODI score of 176 from 104 balls as South Africa posted 353 for six in their 50 overs having been asked to bat, before restricting the visitors to 249 all out in 47.5 overs in their reply. Mahmudullah added 35 to slash the deficit. However, Rubel Hossain put an end to the fiery innings, and to his fellow bowlers' suffering as well.
De Villiers raced to his 25th one-day global century off 68 balls with ten fours and a six.
Amla and Quinton de Kock (46) set South Africa up with a solid opening partnership of 90 but De Villiers' acceleration in the middle and late overs made sure the home team was favourite to take an unassailable 2-0 lead in the three-match series.
Three balls later, Shakib bowled hosts skipper Faf du Plessis before he could open his innings.
De Villiers was the driving force of both those stands, making 86 of the 136 runs he put on with Amla and 90 of the 117 he put on with Duminy. He then proceeded to score 76 runs off the next 36 balls.
The third and final ODI will be played on Sunday (October 22) at Buffalo Park, East London.