We study an optimal control problem for the stationary Stokes equations with variable density and viscosity in a 2D bounded domain under mixed boundary conditions. On in-flow and out-flow parts of the boundary, nonhomogeneous Dirichlet boundary conditions are used, while on the solid walls of the flow domain, the impermeability condition and the Navier slip condition are provided. We control the system by the external forces (distributed control) as well as the velocity boundary control acting on a fixed part of the boundary. We prove the existence of weak solutions of the state equations, by firstly expressing the fluid density in terms of the stream function (Frolov formulation). Then, we analyze the control problem and prove the existence of global optimal solutions. Using a Lagrange multipliers theorem in Banach spaces, we derive an optimality system. We also establish a second-order sufficient optimality condition and show that the marginal function of this control system is lower semi-continuous.