The direct and optimal control solution of the laminar, fully developed, steady MHD flow of an incompressible, electrically conducting fluid in a duct is considered together with the heat transfer. The flow is driven by a constant pressure gradient and an external uniform magnetic field. The fluid viscosity is temperature dependent varying exponentially and the Hall effect, viscous and Joule dissipations are taken into consideration. The control problem is solved by the discretize-then-optimize approach using mixed finite element method for the MHD and energy equations. The control formulations with the Hall and viscosity parameters, the Hartmann and Brinkmann number are given to regain the desired velocity and temperature of the MHD flow. (C) 2018 Elsevier Ltd. All rights reserved.