How to Recover a pattern lock on Xiaomi Without Losing Data

When you pick up your Xiaomi and realize you can’t unlock the screen, it causes panic in any user, thousands of photos, important documents, correspondence and passwords from banking applications are stored in memory, the main thing to realize at this point is not to give in to emotions and randomly go through the combinations, as this can lead to a temporary lock of the device security system.

Modern versions of MIUI and Android have significantly enhanced user data protection, making standard password-bypassing techniques more difficult than a few years ago. However, if you’re prepared in advance or know the specifics of how the system works, there’s a real chance of regaining access to your smartphone without performing a full reset that destroys all information.

In this article, we will take a closer look at the proven ways to get around the lock using built-in Mi Account features, USB debugging or special boot modes. It is important to understand that the success of the operation depends on the version of Android, the model of your device and whether certain settings were enabled before the lock.

Using Mi Account to Unblock

The most civilized and safe way to restore access to the device is to use a tied Mi Account. Xiaomi has a remote device management mechanism that allows you to reset the screen lock if the smartphone has an active Internet connection, this method does not require a connection to the computer and complex manipulation of the code.

To start, you’ll need another device (computer or tablet) from which you can log in to your account. Go to the official Mi Cloud website and log in using the same login and password that you entered on the locked smartphone. If you don’t remember the login details, use the password recovery feature on the site first.

Once you have successfully logged in, search the Find Device section on the menu to try to locate your gadget, and if the status of the device is displayed as Online, you will have a number of actions available, among which we are interested in unlocking. Press the corresponding button and the system will send a command to remove the pattern lock or PIN-code.

📊 Did you have a Mi Account before you were blocked?
Yeah, and I remember the password.
Yeah, but I forgot the password.
No, the account wasn't tied.
I don't know what that is.

⚠️ Note: This method will only work if the locked phone has Internet (Wi-Fi or mobile data) on and the Find Device function is activated. If the screen is completely black or the network is missing, the command will not be executed.

It is worth noting that after this procedure, the pattern lock will be deleted, but the system may require re-entering the password from the Mi Account at the next download for security reasons.

Unlocking through USB debugging (ADB)

If you have previously included in the developer settings Debugging mode USB (USB Debugging, your chances of saving data go up to 90 percent, and this method allows you to send commands from your computer directly to your Android system without having to lock the screen. ADB cable USB.

Connect your smartphone to your computer. If you have a window on your phone asking for debugging permission, unfortunately, you can't confirm it without unlocking it, and it won't work. However, if you've already given permission before ("Always allow this computer"), the system will skip this step.

Open the command line on your computer in the ADB tool folder and enter a command to delete the file that stores the access keys. Depending on the Android version, the path may differ, but the most common instruction is:

adb shell rm /data/system/gesture.key

Or, for older versions:

adb shell rm /data/system/keyguard/gesture.key

Once you have completed the command, restart the device. The lock screen may remain, but any pattern lock or password you enter will be accepted by the system as correct. This is because the physical password hash file has been deleted and the system has reset the check.

☑️ Checking readiness ADB-method

Done: 0 / 4

It is important to understand that on modern versions of Android (11, 12, 13 and later), access to /data/system/ without root rights may be limited even with debugging enabled.

Unlocking the lock through safe mode

Sometimes the locking is not caused by system settings, but by a third-party application that you recently installed. In Safe Mode, the smartphone only boots with system applications, which allows you to bypass the blocker if it is a third-party one.

To enter this mode, you usually need to press the power button and then (hold) the “Switch off” option on the screen until a message appears to indicate a transition to Safe Mode. On some Xiaomi models, the combination may be different: turn off the phone, turn it on, and when the Mi logo appears, press the volume down button.

If you manage to get to the desktop without requesting a password, immediately remove the newly installed applications, especially those that have device administrator rights or are responsible for security.

MethodConditions requiredData retentionDifficulty
Mi CloudInternet, Mi Account100%Low.
ADB CommandUSB debugging enabled100%Medium
Safe regimeThird-party blocker100%Low.
Smart LockConfigured trusted places100%Low.
What if Safe Mode asks for a password?
If Safe Mode requests unlocking, it means that the lock is system, in which case deleting third-party apps will not help, and you need to try methods with an account or ADB.

Smart Lock and Trusted Devices

Users who have pre-set the Smart Lock feature can access the device without entering a password under certain conditions, which allows you to specify “trusted places”, “trusted devices” (such as Bluetooth headphones or smart watches), or use voice recognition.

Check if there is any previously paired Bluetooth device connected to the phone, if you are at home or in an office where a trusted location is set up, GPS-The module can automatically unlock the screen. Try to approach the router or take the phone outside if the trusted location is your address.

It's also worth checking the Google Assistant settings. If you have voice control set up, try saying, "Ok Google, unlock your phone." This method doesn't work on all models and firmware versions, but it's worth trying, because it doesn't require technical knowledge.

💡

Set up Smart Lock immediately after unlocking: Go to Settings → Security → Smart Lock and add a trusted Bluetooth device to have a backup in the future.

Specialized software and service codes

There are many PC programs that promise to unblock without losing data, such as ADB Run, Mi Unlock Tool (the official utility, but it requires unlocking the bootloader, which often leads to a reset), or paid solutions like Dr.Fone, which are often limited in their effectiveness.

Some users try to use service codes that are entered through a dialer, but only access to a call on a locked screen via an emergency call button, codes like ##7780## can reset settings, which is contrary to our goal of data retention.

Be extremely careful with programs that require root access. Obtaining superuser rights on a locked device is often impossible without unlocking the bootloader, and this procedure on Xiaomi officially involves completely removing data from the device for security purposes.

⚠️ Warning: By downloading dubious unlock software from unverified sites, you risk infecting your computer with viruses or transferring data from your Mi Account to third parties.

If none of the gentle methods worked, the option remains to contact an authorized service center Xiaomi.If you have a check about the purchase and a box from the device, engineers can perform the unlock procedure at the hardware level, saving user data, although this service may be paid.

Prevention of blockages and important conclusions

The best way to deal with the problem is to prevent it: back up your sensitive data regularly to the Google Photos or Mi Cloud cloud. Make sure you remember the password from your Google and Mi Account, as these are the keys to recovery.

Write down a pattern lock or PIN-code to a secure location (paper notebook or password manager on another device) Do not rely on memory alone, especially if you rarely use a screen lock (for example, using fingerprint unlock).

💡

The only guaranteed way to avoid data loss when a forgotten password is to regularly back up and link accounts.

Remember that with every Android security update, the ability to bypass passwords without losing data is reduced.What worked on Android 6.0 is likely not going to work on Android 13. So don't waste time on outdated methods from the Internet 5 years ago.

Frequently Asked Questions (FAQ)

Will my phone reset if I enter the wrong password 10 times?
On modern versions of MIUI, after 5-10 failed attempts, the phone is temporarily locked for 30 seconds, then for 5 minutes, and so on. Complete data reset simply by entering a password does not occur until you initiate this action yourself or exhaust the limit of attempts (which is extremely rare due to the exponential increase in lock time).
Can I unlock Xiaomi through Google’s Find My Device?
Google Find My Device used to reset the screen password, but for security reasons, Google removed it a few years ago, and now it can only erase the device (which will delete the data), lock it, or play back sound.
Will the phone be able to reflash without unlocking the bootloader?
Official flashing through the Mi Flash Tool requires an unlocked bootloader. If the bootloader is locked, you can't flash your phone in Fastboot mode. Attempting to flash your phone in Recovery mode can lead to a signature verification error and a failure to install, or data loss if you can start the reset process.
What if I forgot my password and my Mi Account?
In this case, data recovery is almost impossible due to the high degree of protection, you will have to perform a full reset (Hard Reset) through Recovery Mode (clamping the buttons Up + Power), after which the phone will require you to enter the Google or Mi Account that was on it before (FRP protection).