Forgetting the pattern lock on a Xiaomi smartphone is a frustrating situation, but it is not a hopeless one. The main problem is that standard unlock methods (such as Mi Account) often require a factory reset, which results in the loss of all data: photos, messages, contacts. However, there are ways to get around the lock without deleting files if you act carefully and follow the verified instructions.
In this article, we will discuss 4 working methods adapted for Xiaomi smartphones (including Redmi, POCO, Mi models). Importantly, the effectiveness of methods depends on the version of MIUI, the presence of debugging over USB and a tied Mi Account. Some methods require preliminary preparation (for example, ADB enabled), so if you read this in advance, save the article in bookmarks.
We warn you that not all methods guarantee 100% results, and if your phone has data encryption enabled or Find My Device enabled, your chances of saving files are reduced.
1 Unlocking through Mi Account (official method)
The easiest and safest method is to use a linked Mi Account. It works if:
- π± Smartphone connected to the Internet (Wi-Fi or mobile network).
- π Remember the username and password from Mi Account.
- π More than 5 failed key attempts were not made on the device (otherwise you will need to wait).
Instructions:
- On the lock screen, tap Forgot the pattern lock? (or Forgot pattern?).
- Select Sign in via Mi Account.
- Enter your email/phone and password from your account.
- Confirm your login via SMS or email (if two-factor authentication is enabled).
- Create a new pattern lock or PIN-code.
β οΈ Note: If the smartphone is not connected to the network, this method will not work, and after 5 failed attempts to enter the key, the system can block unlocking through the account for 30 minutes or longer.
2.Use of ADB (for advanced users)
The Android Debug Bridge (ADB) method is suitable if USB debugging has been enabled on the smartphone before.This is the only way to unlock the device without losing data if you donβt have access to Mi Account.
What you need:
- π₯οΈ A computer with installed Xiaomi drivers and ADB.
- π USB-cable (preferably original).
- βοΈ Included debugging by USB (Settings β The phone. β Version. MIUI β 7 times tap to unlock Developer Mode, then turn on Debugging by USB).
Step-by-step:
1. Connect your smartphone to your PC via USB.
2. Open the command line (Windows) or the terminal (Mac/Linux).
3. Enter the commands in turn:
adb devices
adb shell
su
rm /data/system/gesture.key
reboot
4. After the reboot, the pattern lock will be reset.β οΈ Attention: If debugging is on USB It wasn't enabled in advance, it won't work. Also on some Xiaomi models (e.g. Redmi Note 12 Pro).+) It may be necessary to unlock the bootloader, which will lead to a data reset.
βοΈ Preparation for unblocking through ADB
3. Unlock via TWRP (for stitched devices)
If your Xiaomi has a custom TWRP recap, you can manually delete the file with the pattern lock, which is suitable for users who have previously unlocked the bootloader and installed TWRP.
Instructions:
- Turn off your smartphone.
- Press the Power button + Volume up to enter TWRP.
- Select Advanced β File Manager.
- Go to /data/system/.
- Delete the files: gesture.key (pattern lock), password.key (if PIN is installed), locksettings.db (locking settings).
Reset the device.
β οΈ Warning: Deleting locksettings.db may reset some security settings, but the data (photos, videos, messages) will remain intact. TWRP request a password for mounting /data, Enter the old pattern lock (even if it doesnβt work on the lock screen).
| Method | Conditions required | Data retention | Difficulty |
|---|---|---|---|
| Mi Account | Linked account, Internet | β Yes. | β |
| ADB | USB debugging enabled in advance | β Yes. | βββ |
| TWRP | Established custom recaveri | β Yes. | ββββ |
| Fastboot (reset) | Unlocked loader | β No. | ββ |
4. Bypassing locks via Safe Mode (for older versions of MIUI)
On Xiaomi smartphones with MIUI 8-10, you can try logging into Safe Mode and removing the pattern lock through settings. This method doesnβt work on all devices, but it sometimes helps.
How to activate Safe Mode:
- On the lock screen, hold the switch off button.
- Tap and hold the power off (or Reboot to Safe Mode, if there is one).
- Confirm the reset.
After entering Safe Mode:
- Go to Settings β Lock and Protection β Lock the screen.
- Enter any pattern lock (the system may miss the check).
- Set a new PIN or turn off the lock.
- Reboot your smartphone.
β οΈ Attention: On new versions MIUI 12+ This method usually doesn't work because of the increased protection, and some features, such as gallery access, may also be disabled in Safe Mode.
π‘
If you have Google Photos or Mi Cloud enabled, important data (photos, contacts) can be restored even after reset. Check your backup settings in your Mi Account before you start unlocking.
5. What should I do if nothing helps?
If all of these methods fail, there are two options:
- Contact the Xiaomi service center β official centers can unlock the device on documents (passport, check), but the guarantee of data preservation is not given.
- Fastboot resets will cause total data loss, but it will return access to your smartphone. To do this, turn off your phone. Press the Power button + Volume down to log into Fastboot. Connect to your PC and execute the command: fastboot erase userdata
Critical information: On Xiaomi models with Qualcomm Snapdragon processor (e.g. POCO F3, Redmi K40) after reset via Fastboot, you may need to flash through the Mi Flash Tool, as the system will stop booting.
6.How to protect yourself from blocking in the future?
To avoid the problem of a forgotten pattern lock, follow the simple rules:
- π Use it. PIN-code instead of a pattern lock, it is easier to remember.
- π± Attach Mi Account and enable data synchronization.
- π§ Turn on Debugging. USB and keep a backup copy through ADB Backup: adb backup -apk -obb -shared -all -f backup.ab
- π Write the key in a secure location (for example, in a password manager).
Itβs also helpful to set up a Smart Lock in Android so that unlocking happens automatically in trusted places (such as at home or work). β Lockdown and protection β Smart Lock.
What to do if your smartphone asks for a password after resetting?
FAQ: Frequent questions
Can you unlock Xiaomi without losing data if USB debugging is not enabled?
Does the method work with gesture.key removal on MIUI 14?
What happens if you enter a pattern lock 10 times incorrectly?
Can I unlock Xiaomi through my Google Account?
How do I know if USB debugging is enabled if my phone is locked?
π‘
If your Xiaomi has enabled data encryption (by default on new models), then deleting key files via ADB or TWRP will lead to loss of access to all data β the system will require a password to decrypt after rebooting.