This article deals with the optimal tracking control problem for spacecraft formation flying via a sliding mode approach in the presence of external disturbances and signal quantization, where both state quantization and input quantization are considered. First, the Gauss pseudospectral method is adopted to solve the multi-objective optimization problem, where performance optimization, thruster amplitude constraints, and collision avoidance are simultaneously taken into consideration. Second, a novel quantized sliding mode control strategy is developed by employing a dynamic logarithmic quantizer to track the obtained optimal trajectories of relative position and velocity. In this design, the quantizer parameters are input into the designed controller to compensate for the signal quantization effects. Under the proposed robust quantized sliding mode control strategy, the resulting closed-loop control system is asymptotically stable with satisfying performance multi-objective constraints. Finally, a simulation example is presented to show the effectiveness of the proposed control design scheme.