The invention discloses a method for building an artificial fish swarm algorithm fractional order PID controller of an axial mixing magnetic bearing. The method for building the artificial fish swarm algorithm fractional order PID controller of the axial mixing magnetic bearing comprises the steps that (1) comparison is carried out between an axial displacement signal of the axial mixing magnetic bearing and a given displacement reference position signal to obtain a displacement deviation signal, the displacement deviation signal is input into a conventional fractional order PID controller; (2) fish swarm scale, a sight range, a moving step length, a crowding degree factor, a maximum attempt limit and maximum iterations are set; (3) the states of each artificial fish include a proportion coefficient, an integral coefficient, a differential coefficient, a differential degree coefficient and an integral degree coefficient; (4) calculation is carried out on an initial fish swarm, current-moment artificial fish food concentration, a fish swarm visual field and a step length; (5) each artificial fish carries out foraging calculation, gathering calculation, and tailgating calculation to update the position of the artificial fish, and finally outputs an optimal parameter. The method for building the artificial fish swarm algorithm fractional order PID controller of the axial mixing magnetic bearing integrates the advantages of an artificial fish swarm algorithm and the advantages of the fractional order PID controller, real-time optimization is carried out on parameters of the fractional order PID controller according to performance indexes of a system, the system can have better static stability and better dynamic stability, and the self-adaptation capacity of the system is improved.