The invention relates to the technical field of garbage truck auxiliary equipment, in particular to an automatic loading and unloading mechanical arm of a compression garbage truck. The automatic loading and unloading mechanical arm comprises oil cylinders, telescopic rods, a first electric rotating shaft, a second electric rotating shaft, a third electric rotating shaft, a knock rod, a knock block, an object plate, baffles, a lock plunger, a rotating plate, electric telescopic rods, press plates and a garbage can. The number of the oil cylinders is two, and the telescopic rods are arranged inthe two oil cylinders. The tail ends of the two oil cylinders are fixedly connected through a first electric rotating shaft. The second electric rotating shaft is arranged between the inner side walls of the heads of the two oil cylinders. The third electric rotating shaft is arranged between the heads of the two telescopic rods. The knock rod is arranged on the second electric rotating shaft. The automatic loading and unloading mechanical arm is simple in structure and convenient to operate, the garbage can is fixed firmly, the garbage can is effectively prevented from sliding off from multiple directions, and safety of the garbage can is protected; and meanwhile, a knock vibration mechanism is arranged, garbage dumping work is accelerated, garbage is dumped more thoroughly, and high practicality is achieved.