A sliding mechanism for an electronic device is provided. The sliding mechanism includes a slide rail assembly and a driving assembly. The slide rail assembly includes a fixed member and a slide rail, the fixed member is fixed to a housing assembly of the electronic device, the fixed member is provided with a sliding slot, and an end of the slide rail is slidably limited in the sliding slot. The driving assembly is fixed to the housing assembly, the driving assembly includes a driving unit connected to the slide rail in a one-to-one correspondence, and the driving unit is configured to drive the slide rail to slide from the housing assembly to the outside and to slide from the outside to the housing assembly.