How to remove the pattern lock on Xiaomi without losing data: proven methods

The forgotten pattern lock on Xiaomi’s smartphone is a situation that even power users face. The main problem is that most standard unlocking methods (such as Mi Account) require a factory reset, resulting in the complete loss of photos, contacts and apps. However, there are methods to bypass the lock without deleting data – if you act quickly and correctly.

In this article, we will discuss 5 working ways to remove the pattern lock on Xiaomi, Redmi and POCO devices (including the models from 2023-2026 on MIUI 14/15). Importantly, the effectiveness of methods depends on the firmware version, the availability of debugging over USB and the associated Mi Account. Some options work only when strict conditions are met - we will also describe them in detail.

1 Unlocking with Mi Account (if the phone is connected to the Internet)

The most official and safe way is to use a linked Mi Account. It is suitable if:

  • πŸ“Ά The phone is connected to Wi-Fi or mobile network.
  • πŸ”‘ Remember the username and password from Mi Account.
  • πŸ“± Synchronization with the account is enabled on the device (checked in Settings). β†’ Mi Account β†’ Synchronization).

After 5 failed attempts to enter the pattern lock, the system will offer the option Forgot the password?. Click on it and follow the instructions:

  1. Enter the email or phone number associated with the Mi Account.
  2. Confirm your identity via SMS or email.
  3. Create a new pattern lock or PIN-code.

⚠️ Note: If two-factor authentication is enabled on your device, you will need access to a backup email or Google Authenticator app. Without this, unlocking through your account is impossible.

This method works on all modern models (Xiaomi 13/14, Redmi Note 12/13, POCO F5/X5), but requires an active Internet connection. If Wi-Fi is turned off, try connecting to the network through the recovery mode (discussed below).

πŸ“Š What kind of smartphone you Xiaomi?
Xiaomi 13/14 series
Redmi Note 12/13
POCO F5/X5
Another Xiaomi
Not Xiaomi.

2. use ADB (if USB debugging is enabled)

If the phone has previously been activated debugging via USB (Settings β†’ About Phone β†’ MIUI Version β†’ 7 times press to unlock the developer mode), you can delete the key file via Android Debug Bridge (ADB).

  • πŸ”Œ Debugging by USB plugged.
  • πŸ’» You have access to a computer with installed Xiaomi drivers and ADB.

Step-by-step:

  1. Connect your phone to your PC through USB-cable.
  2. Open the command line (Windows) or terminal (macOS/Linux) and type:
adb shell


su




rm /data/system/gesture.key




rm /data/system/locksettings.db




rm /data/system/locksettings.db-wal




rm /data/system/locksettings.db-shm




reboot

Once you reboot, the pattern lock will be reset, and if the su command doesn't work, then there are no root rights on the device, try an alternative method:

adb shell


cd /data/data/com.android.providers.settings/databases




sqlite3 settings.db




update system set value=0 where name='lock_pattern_autolock';




update system set value=0 where name='lockscreen.lockedoutpermanently';




.quit




reboot

⚠️ Attention: MIUI 14/15 The path to the key files may be different. If the commands don't work, check the current paths through adb shell ls. /data/system/.

Install Xiaomi drivers on PC|Download ADB Tools (platform-tools)|Enable debugging on USB on the phone (if possible)|Prepare original USB-cable (not charging!)

-->

3. Unlock through Recovery Mode (TWRP)

If you have a custom TWRP recap on your phone, you can manually delete the pattern lock files, which is suitable for advanced users and requires:

  • πŸ› οΈ Established TWRP Recovery (not standard Mi Recovery).
  • πŸ”‹ Battery charge of at least 50% (to avoid failures).
  • πŸ“ Backup of data (recommended, but not necessarily).

Instructions:

  1. Turn off the phone.
  2. Press Volume Up + Power to Enter TWRP.
  3. Go to Advanced β†’ File Manager.
  4. Delete files: /data/system/gesture.key /data/system/locksettings.db /data/system/locksettings.db-wal /data/system/locksettings.db-shm

Reset the device.

If after the reboot there is a request for input PIN-In the code (instead of the pattern lock), enter any set of numbers – the system will let you go further.

Xiaomi modelSupport for TWRPRisk of data loss
Xiaomi 13/14❌ No official version.High (brick possible)
Redmi Note 12 Pro+βœ… Yes (unofficial assemblies)Medium.
POCO F5βœ… Yes.Low.
Redmi 10Cβœ… Yes.Low.

⚠️ Attention: Installation TWRP New Xiaomi models (2023-2026) can lead to locking the bootloader and turning the phone into a β€œbrick”. XDA Developers.

4. Circumvention through service codes (for older models)

On Xiaomi devices before 2019 (on MIUI 10 and below), sometimes bypassing service codes worked.The method is not guaranteed, but can help if other methods are not available.

Try the following combinations:

  • πŸ“ž Dial in the dial number: # # #7378423## (service menu).
  • πŸ”’ Go to Service tests β†’ Security β†’ Lock screen and try to reset the key.
  • πŸ“± On some models (Redmi) 4/5) code: ##3646633## β†’ Security β†’ Clear lock data.

If the codes don't work, the manufacturer has closed the vulnerability in the new firmware. Don't try random combinations, it can cause hardware failure.

Why did the service codes stop working?
Since 2020, Xiaomi has tightened security policies in MIUI, and service menus that allowed the lock to be reset have been removed or protected by access control, and these codes now only work on older models (Redmi 3/4, Mi A1) or firmware below MIUI 11.

5. Contact the Xiaomi Service Center (guarantee cases)

If the independent attempts are unsuccessful, you can contact the official service center. Xiaomi can unlock the device without losing data if:

  • πŸ“„ You have a check or a warranty card (proof of possession).
  • πŸ”‘ Phone linked to Mi Account with confirmed email.
  • πŸ“± The model is not blacklisted (stolen/lost devices).

The procedure takes from 1 to 3 days, the cost of the service is from 1000 to 3000 rubles (depending on the model and region), in some cases, unlocking is free, if the device is warranted.

List of official Xiaomi service centers in Russia:

  • πŸ“ Moscow: 12 addresses (including M.Video, Svyaznoy).
  • πŸ“ St. Petersburg: 8 addresses (Marshala Govorov Street, 35, etc.).
  • πŸ“ Regions: check on the official website.

⚠️ Attention: Unofficial services often offer "unlock without loss of data" for 500-800 rubles. Risks: installing spyware, damaging firmware or stealing data.

πŸ’‘

Before visiting the service center, take a screenshot of the IMEI phone (on the box or via the *#06# command) and this will speed up the confirmation process.

What do you do if nothing helps?

If all of these methods fail, you'll have a hard reset through Mi Recovery, which will cause you to lose data, but it will return access to your phone.

  1. Turn off the device.
  2. Press Volume Up + Power before the Mi logo appears.
  3. Choose Wipe Data β†’ Wipe All Data.
  4. Confirm the reset and wait for the reset.

Once reset, the phone will look like new, so you can recover the data.

  • πŸ“² Restore contacts and notes via Mi Account (if sync was enabled).
  • πŸ–ΌοΈ Photos and videos can be returned from Google Photos or Mi Cloud.
  • πŸ“₯ Installed apps are restored from the Mi App Store (Section "My apps").

If the β€œFind Device” feature (Settings β†’ Mi Cloud β†’ Find the device) was enabled on the phone, try remotely locking the phone and setting a new password through the i.mi.com web version.

πŸ’‘

Hard reset is the last option. Before you do it, make sure that your phone has de-linked to your Google account (FRP), or you will need to enter your old account details after the reset.

FAQ: Frequent questions about unlocking Xiaomi

❓ Can I remove a pattern lock through a Google Account, like on Samsung?
No. On Xiaomi, the Google Account Unblocking (FRP) function only works after a hard reset, not to bypass the pattern lock. If you forget the key, Google won't help here, just Mi Account or ADB.
❓ Why does the phone ask for the key after removing gesture.key?
This means that the lock is stored not only in gesture.key, but also in other files (for example, locksettings.db). Try to delete all the files listed in the TWRP section or repeat ADB commands with su rights.
❓ Does the method of calling a blocked phone work?
No. In the past, some models had the ability to access the menu and disable the lock, but in MIUI 11 and later, this vulnerability is eliminated.
❓ Can you unlock Xiaomi via Fastboot?
Partially. You can reset your settings to factory settings on Fastboot (fastboot erase userdata command), but that will cause data loss. You can't bypass the pattern lock without resetting through Fastboot, you need ADB or TWRP rights.
❓ How to avoid data loss in the future?
So that you don't have to face the problem again: πŸ” Use it. PIN-code instead of a pattern lock (it is easier to recover via Mi Account). ☁️ Enable automatic sync with Mi Cloud or Google Drive. πŸ“± Make backups regularly through Settings β†’ System system β†’ Backup. πŸ”§ Write down the bootloader unlock code (if you plan to install it) TWRP).