Image definition will be influenced by alignment errors of mirrors in an optical system consisting of hyperbolic, parabolic or ellipse mirrors. The major factors of alignment errors are gravity, wind loads and heat exchange for some optical systems like ground-based telescopes, while vibration and temperature gradient for systems like space telescopes. Larger telescopes are more sensitive to these error sources, which becomes the concerns of researchers. So the alignment errors of mirrors must be corrected in time to keep systems working in best condition. In order to solve the problem, many methods are proposed based on the detection of wave-front errors using wave-front sensors like Hartmann-Shack. However, wave-front sensors may not be used or cause optical systems to be more complicated. For example, multi-fields must be tested when telescope is working. On the one hand, if a wave-front sensor is used, it must be moved around imaging plane, on the other hand, if more wave-front sensors are used, system must be more complicated. So a new method is discussed for alignment error correction by evaluating the quality of spot diagrams based on the using of stochastic parallel gradient descent (SPGD) algorithm. The method considers the performance metric like spot diagram radius as a function of control parameters and then uses the SPGD optimization algorithm to improve the performance metric. The control parameters include positions of mirrors. The iteration process must be used in the right way to control position parameters. If it is not considered, a problem may come up that positions of spot diagrams may be influenced by the iteration. Furthermore, spot diagrams will probably disappear from detectors. Then the radii of spot diagrams are not correct. So a better way is put forward by the combination of de-center and tilt of mirrors. The way ensures that the position error produced by de-center and tilt are compensated for. A formula is provided in this paper to give the relationship between them. Based on the analysis, an optical system is designed to verify the conclusion. The SPGD algorithm is achieved by computer programming and the position of the mirror is controlled by a hexapod. Firstly, the problem is verified that the spot diagram will disappear from the detector with a normal iteration process. Then the new way is implemented. In the iteration process, the spot diagram is always in the center of the detectors. In order to prove the feasibility of the method, three different alignment errors are tested and all of them each give an Airy disk finally. The experiment can provide reference for engineering practice.