Forgot the code on Xiaomi: how to unlock the screen

When you pick up your Xiaomi and realize you've forgotten the unlock code, it's one of the most stressful things for a smartphone owner: the screen burns, notifications come, but you can't log in, and all the data is locked, most often after a long password change, a complex combination of "security" or a banal distraction.

In this article, we will discuss all the current ways to restore access to your device, from simple methods through the cloud to a radical reset via Recovery. It is important to understand that modern Android security systems and MIUI or HyperOS shells are designed to protect your personal data from strangers as much as possible, so simply “bypass” your password without losing data in most cases will not work.

But don’t despair: there are proven algorithms that will help bring the phone back to life, we will look at options for different versions of firmware and models, explain the nuances of working with your Mi Account and Google account, and warn about typical errors that can permanently lock the device.

Unlocking with Mi Account and Find Device

The most civilized and safest way to restore access to your phone if you forget the code is to use a cloud service from the manufacturer. Find Device allows you to remotely control your smartphone, including the ability to reset the screen lock, which requires that the device has logged in to the Mi Account, and the function itself was activated in the settings.

The unlocking process is as follows: you need to go to the official i.mi.com website from any other device (computer or phone) and log in under the same account that is used on the locked smartphone. After logging in, select your device from the list and find the option “Unlock” or “Wipe Data”.

⚠️ Note: Remote reset via Mi Account will result in the complete removal of all user data from the phone's internal memory.Photos, contacts and apps will be lost if no backup was made.

This method only works if you have an active Internet connection on a locked device, if the phone is in flight mode or the network is not configured, the command from the server will not be executed, and it is worth considering that after the reset, the system will require you to enter a password from the Mi Account to confirm ownership, which is part of the Anti-Theft protection system.

💡

If you do not remember the password from your Mi Account, try to restore it through the Forgot Password form on mi.com before you start unlocking your phone.

Resetting with Recovery Mode (Hard Reset)

If cloud services are not available or the phone is not connected to the Internet, the only option is a forced reset via the Recovery Recovery menu, which is universal and works on all Xiaomi, Redmi and Poco models, regardless of the firmware version, the essence of the method is to load a special mode that minimizes the functionality of the system for diagnostic and recovery operations.

To get into this menu, you need to turn off your smartphone completely. Then press the button combination: usually a Volume Up and a Power button. Hold them together until the Mi logo appears, then release the power button, continuing to keep the volume up until the main Recovery menu appears.

☑️ Hard Reset algorithm

Done: 0 / 4

In the menu, you can navigate with volume buttons (up/down), and the choice is confirmed by the power button. You need to find the Wipe Data item and select it. Then the system can offer several options, among which you can choose Wipe All Data. Confirm the action by selecting Confirm.

⚠️ Note: Some new models with HyperOS shell or fresh MIUI 14 to log into Recovery, it may be necessary to unlock the screen, making this method useless if the code is forgotten.

Once the cleanup process is complete, the phone will restart. The first turn on may take more than the usual time, from 5 to 15 minutes, as the system recreates the file structure.Be prepared for the device to request a Google account that was synced earlier (FRP protection).

Use of the “Forgot Password” function on the input screen

In some older versions of the MIUI shell, as well as when certain types of locking are used (such as a pattern lock), the password entry screen may display a link “Forgot the password” or “Forgot the pattern lock” that usually becomes active after several failed attempts to enter or after a certain period of time.

Clicking on this link, the system will prompt you to enter data from your Mi Account or Google Account that was linked to the device. If you remember the username and password from the cloud service, this will instantly remove the lock without losing data.

If the link does not appear after 5-10 attempts to enter the wrong code, then in your version of the firmware this security mechanism is not implemented or disabled by the manufacturer.

Why did the “Forgot Password” button disappear?
Google and Xiaomi are gradually removing the ability to reset passwords without losing data to protect user information in the event of phone theft.

Unlocking the lock via USB debugging (ADB)

This method is only suitable for advanced users and requires prior preparation. USB (USB Debugging) in the Developer menu, you can try to delete the lock files via your computer, USB-cable and installed platform ADB (Android Debug Bridge).

Connect your phone to your computer and run the command prompt or terminal in the ADB folder. Enter the adb device command to make sure the device is recognized. If a debugging permission window appears on your phone screen and you can't confirm it because of the lock, this method, alas, will not work.

If access is allowed, you can try to delete the files that store the password hash. Enter the following commands sequentially:

adb shell rm /data/system/gesture.key


adb shell rm /data/system/password.key




adb reboot

Once the reboot is over, the lock should disappear and you can set a new pin, but it’s worth noting that on data-encrypted devices (which is the default on all modern Xiaomi), this method may not work, since without unlocking the screen, access to the ADB file system is closed.

📊 What type of lock you are using?
pattern lock
Digital. PIN-code
A complex password
Fingerprint.
Face ID

What to do if your phone requires a Google account (FRP)

After a successful Hard Reset, you may encounter an activation screen where the system will require you to enter a login and password from a Google account that was previously synced with the phone, a feature called FRP (Factory Reset Protection) designed to make the stolen phone useless for an attacker.

If you remember your account, just type it in. If you forgot your Google password, or if you got your phone from a previous owner who didn't log out, things get complicated. In the first case, restore access to Google email from any browser on another device.

The second is to contact the previous owner, without this data, it is almost impossible to unlock the device legally. There are bypass FRPs, but they depend on the specific version of Android and the security patch, often require complex software and do not guarantee the result.

Unlocking methodData retentionWe need the Internet.Difficulty
Mi Cloud (Find Device)No.Yes.Low.
Recovery Mode (Hard Reset)No.No.Medium
ADB (USB Debugging)Yeah (possibly)No.Tall.
Service centreNo.No.Low.

Prevention and backup

To avoid the situation of “forgetting the code on Xiaomi” catching you off guard in the future, it is important to regularly back up. Xiaomi smartphones have a built-in backup tool. Go to Settings → About Phone → Backup and Restore.

You can set up automatic data storage to the Mi Cloud or external drive, and always keep the Find Device feature on and periodically check the relevance of passwords from your accounts, write down a complex password to a secure location or use a password manager.

💡

Regular backup is the only way to ensure that you do not lose important information when resetting your password.

It's also useful to know that on some models with a fingerprint sensor or a face scanner, unlocking with biometrics can work even if you forget the digital code, but only until the first restart of the device.

Frequently Asked Questions (FAQ)

Can I unlock Xiaomi without losing data?
Officially, almost not unless the "Forgot Password" feature on the input screen is activated. Modern Android security standards encrypt user data with a key tied to the lock password. Without a password, you can not read the data. Third-party programs that promise to unlock without losing data are 99% fraud or viruses.
What if the phone says “Device locked” after resetting?
This is Mi Account or Google FRP protection. You need to enter the username and password from the account that was on the phone before the reset. If you don't remember them, restore the account through the manufacturer's website. If the phone is someone else's, return it to the owner.
How many times can I enter the wrong password?
After 5 failed attempts, the phone will lock for 30 seconds. Then the intervals will increase (1 minute, 5 minutes, 30 minutes). After many attempts, the device may offer a data reset or completely lock before entering the correct Mi Account.
Will the phone flashing help?
Fastboot (Mi Flash Tool) flashing will also result in complete deletion of data, and if the bootloader is blocked on the phone, you can't flash it without unlocking it, which requires access to the phone's menu, which is a vicious circle, so flashing it is not a solution to the forgotten password problem.