When a smartphone owner suddenly finds he or she has forgotten a pattern lock or a digital code, it is much more common than people think, especially for Xiaomi devices where MIUI security can block access after several failed typing attempts. Users often panic, believing that the only way out is a complete factory reset that is guaranteed to destroy all photos, contacts and important documents.
Fortunately, modern versions of Android and the MIUI have lock-bypass mechanisms to save user data. However, the success of the event depends on whether certain preparatory actions, such as linking an account or enabling debugging over USB, were performed in advance. In this article, we will discuss all possible scenarios, from standard recovery methods to more complex technical solutions.
It is important to understand that there is no universal “magic button” that will work for absolutely all models and versions of firmware. Methods that work on the Redmi Note 10 with Android 11 may not be useful on the Xiaomi Mi 9 running an older version of the software.
Use the “Forgot Password” function through your Mi Account
The most reliable and regular way to restore access to the device without data loss is associated with the use of the cloud service Mi Account. If you previously logged in to Xiaomi on a locked phone, your chances of success are maximum. MIUI allows you to reset a pattern lock or pin code, confirming the identity of the owner through the company's servers.
To implement this method, the lock screen must offer the option “Forgot password” or “Forgot the pattern lock” after five incorrect attempts to enter. By clicking this button, the system will require you to enter the username and password from your Mi Account. Entering data from your Google account in this particular window will not help, it requires a Xiaomi account. Once you successfully log in, the lock will be removed, and you will be able to specify a new access code.
⚠️ Note: If the phone is not connected to the internet at the time of the recovery attempt, the confirmation button may not work.
In some cases, especially older versions of MIUI, you may need to click on the reset link. If you don't have one on the lock screen, you may have disabled the feature in the security settings before. Check if you have a linked account by trying to remember if you were logged in to Xiaomi services when you first set up the device.
Recovery through Google Find My Device
An alternative, but less guaranteed, way is to use Google Find My Device, which previously allowed you to directly change your screen lock password remotely, but in modern versions of Android, this feature has been eliminated for security reasons.
To try this method, you need to log into your Google account from any other device (computer or tablet) through your browser. Go to the official service page and select a locked smartphone from the list of available devices. If the system sees the device, you will be prompted with several actions: call, block or clear the data.
- 📍 Location: Lets you see where your phone is, which is useful if you’re not sure if you’re holding it.
- 🔒 Device locking: In rare cases, it allows you to set a new temporary password that will replace the forgotten code.
- 🗑️ Cleaning the device: an extreme measure that will delete all data, so only use it if the information is not important.
It's worth noting that to run this service, the phone needs to have the Internet on and geolocation activated. If the device is in flight mode or discharged, the command will not be executed. It's also important that the device has the latest Google Play services installed, which is relevant for global firmware versions, but does not always work on Chinese versions of MIUI without flashing.
💡
If Google Find My Device shows the device as “Offline,” try sending a command to lock or clean up — it will run automatically as soon as the phone appears on the network.
Unlocking through debugging via USB and ADB
The most technically sophisticated but powerful method involves the use of the ADB (Android Debug Bridge) toolkit, which only works if the locked phone previously included USB debugging in the developer menu and the computer was given permission to access. If these conditions are met, you can delete the file that stores the access keys through the command line.
First, you need to download and install the Platform-tools package on your computer. Connect your smartphone to your PC through the original one. USB-Open the command line (CMD) or terminal in a toolbox ADB And you type in the connection check command: adb devices. If a device has been listed, it's connected.
adb shell rm /data/system/gesture.key
adb shell rm /data/system/password.key
adb shell rm /data/system/locksettings.db
adb shell rm /data/system/locksettings.db-wal
adb shell rm /data/system/locksettings.db-shmExecuting these commands will delete the files responsible for storing the pattern lock and pin code. Once the device is reboot (adb reboot), you can log in without entering a password or with any arbitrary set of characters. However, if the phone has never connected to this computer before and you have not confirmed debugging, the method will not work due to Android security requirements.
What if the ADB can’t see the device?
Third-party utilities to remove the lock
There are many third-party software that promise to unlock Xiaomi’s phone without losing data. Popular solutions include Dr.Fone, Tenorshare 4uKey, and iMyFone LockWiper. These utilities use vulnerabilities in the system or specific firmware bugs to bypass the lock screen.
The effectiveness of these programs varies greatly depending on the phone model and the version of Android. On new devices with updated security, the chances of success without losing data tend to zero. Most often, these tools still offer the “Remove Screen Lock” feature, which is technically a data partition formatting, which leads to loss of information.
| Programme | Xiaomi support | Risk of data loss | Cost |
|---|---|---|---|
| Dr.Fone | Partial | High-pitched | Paid |
| Tenorshare 4uKey | Limited. | Medium. | Paid |
| Android Multi Tools | High (ADB) | Low (with rights) | Free. |
When using third-party software, you should be aware of the potential privacy risks: Giving full permissions to access your device to unknown software can lead to a leak of personal data. Always download utilities only from official developer sites and check files with antivirus before launching.
☑️ Checking before using the software
Precautions and preparations for discharge
If none of the gentle methods worked and you are faced with the need for a full reset, it is crucial to prepare for this process correctly.Reset will return the phone to factory state by removing all user files, applications and settings. However, if you have a backup, you will be able to quickly recover important information.
First of all, check if your contacts and photos are synced to the cloud. For contacts, this can be a Google account or Mi Cloud, for photos, Google Photos or Xiaomi Gallery. Go to the relevant websites from your computer and make sure that your data is there. This will allow you to not worry about losing it after formatting.
⚠️ Warning: After resetting the settings, the phone will require you to enter a Google account that was previously synced with the device (protection) FRP). Make sure you remember the login and password from it, otherwise the phone will turn into a brick».
It is also worth removing the MicroSD card before the reset procedure, if installed. Although modern versions of MIUI usually store application data in internal memory, the card may have personal files that are better not to risk random formatting.
💡
Backup is the only 100% way to ensure data is safe, and set up autosynchronization of important files to the cloud regularly.