Where is the 20-digit security code on Xiaomi: the complete guide

If you’re looking for a 20-digit security code on a Xiaomi device, it’s likely to be unlocking a bootloader, restoring access to your Mi Account account, or resetting your graphical password, a unique code that’s generated by the system and required in critical situations like a forgotten password, buying a used phone with a tied account, or failing to update your firmware.

Unlike the standard ones. PIN-For codes or graphics keys, Xiaomi’s 20-digit security code doesn’t show up in the default settings; it either needs to be requested through official channels or extracted from system files — and both are nuanced. In this article, we will discuss all the current methods of obtaining code, including hidden menus, developer tools and appeal in support of Xiaomi.

What is Xiaomi’s 20 digit security code and why you need it?

The 20-digit code is a unique identifier that is linked to the device’s IMEI and Mi Account, and it performs several key functions:

  • 🔓 Unlocking the bootloader to install custom firmware or restore the system after a failure.
  • 🔄 Resetting your Mi Account when buying a used phone if the previous owner did not untie the device.
  • 🛡️ Proof of ownership in Xiaomi Support in case of dispute (e.g. theft or loss).
  • 🔧 Restoring access to the device after a failed update or reset settings.

It is important to understand that this code is not static — it can change after resetting, flashing or changing your account. Besides, it can not be picked up or generated manually, Xiaomi’s system uses a complex encryption algorithm tied to the hardware data of the device.

⚠️ Warning: Never share a 20-digit security code with third parties! scammers can use it to remotely reset your device or link to their Mi Account.

Where is the 20-digit code physically stored on a Xiaomi device?

The code doesn't show up in the standard MIUI interface, but it can be extracted from system files or retrieved through official channels.

Source of codeHow to getWhen it works
Hidden menu ##4636##Enter the combination in the dialer → go to “Phone Information”Only some models up to MIUI 12
File /data/data/com.android.providers.settings/databases/settings.dbRoot access is required or ADB-teamOn all devices, but you need technical skills
Xiaomi official website (unlocking the bootloader)Request via en.miui.com/unlockOnly to unlock the bootloader
Xiaomi support (via ticket)Provide proof of purchase and IMEIWhen you lose access to your account

Since MIUI 13 and later, Xiaomi has tightened security policies, and most of the holes for extracting code without formal request have been closed. For example, previously the code could be found in system logs via ADB logcat, but now this data is encrypted.

📊 Why you need a 20-digit Xiaomi code?
Unlocking the loader
Resetting the Mi Account
Post-discharge recovery
Other

How to find a 20-digit code through hidden menus (for older models)

If your device is released before 2021 and runs on MIUI 12 or older, there is a chance to extract the code through the engineering menu.

  1. Open the Phone app and enter the combination: ##4636###.
  2. In the menu that appears, select “Phone Information” item.
  3. Scroll down to the "Wi-Fi information" or "Battery information" section.
  4. Press and hold any item in this section for 5-10 seconds.
  5. If the code is available, a pop-up window with a 20-digit combination will appear.

This method doesn’t work on all devices, for example, on Redmi Note 10 Pro or Poco X3 Pro, the menu may be missing or incomplete. If the combination doesn’t work, try the alternative code: ##7378423## (for some Redmi models).

⚠️ Note: Do not enter random engineering codes on new devices (MIUI 14+) — This can lead to resetting or blocking. IMEI.

Install Xiaomi drivers on PC|Enable debugging on USB customized|Download the platform ADB (Android SDK)|Connect the phone to the PC in the mode "Transfer of files"-->

Extracting code through ADB (for advanced users)

If you have access to the debugging USB (USB Debugging, you can try extracting code using ADB. This method requires minimal knowledge of working with the command line.

Instructions:

  1. Connect the device to your PC and open the terminal (or PowerShell on Windows).
  2. Enter the command to check the connection: Adb devices Make sure your device appears in the list.
  3. Launch the ADB: Adb shell shell shell
  4. Run the command to search for code in system settings: sqlite3 /data/data/com.android.providers.settings/databases/settings.db "SELECT * FROM secure WHERE name LIKE '%miui%'";

If the code is stored in a database, it will be displayed in the output of the command. Note the lines containing miui.security.code or lockscreen.password_salt. New devices (MIUI 14+) This method may not work due to data encryption.

What if ADB does not find the code?
If the command returns an empty result, try an alternative method: 1. Download the backup of the settings via adb backup. 2. Unpack the.ab file using the abe tool (Android Backup Extractor). 3. Check the files in the folder /apps/com.android.providers.settings/db/. Note: this method requires an unlocked bootloader or root rights.

Official code request via Xiaomi support

If the independent methods do not work, you need to contact Xiaomi support, which is suitable for:

  • 📱 Restoring access to Mi Account when buying a used phone.
  • 🔓 Unlock the bootloader if the official Mi Unlock tool gives an error.
  • 🛠️ Reset the device after a failed update (for example, “brick” after firmware).

Algorithm of action:

  1. Go to the support site account.xiaomi.com and log in (or create a new account).
  2. Select the "Help" section" → "Lost access to the device".
  3. Fill out the form by specifying: IMEI device (you can find in Settings → About phone → All specs or on the box). Serial number (S/N). Check or proof of purchase (photo box, warranty card).

Confirm the request via email or SMS.

The request is processed between 24 hours and 7 days, and in some cases, support may request additional data, such as a photo of the device with the screen on (to confirm that the phone is not in the hands of fraudsters).

⚠️ Note: If you bought the phone with your hands, make sure the previous owner untie the device from their Mi Account.Otherwise, Xiaomi support will refuse to provide the code, citing security policies.

💡

Before contacting in support, take a picture of the IMEI and the serial number from the sticker under the battery (if the phone is collapsible) – this will speed up the processing of the request.

Frequent Mistakes and How to Avoid Them

When working with a 20-digit security code, users often encounter typical problems, and here are the most common ones and how to solve them:

Mistake.Reason.Decision
The code is not suitable when unlockingThe device is linked to another Mi AccountSeek support for proof of purchase
ADB does not find the databaseNo root rights or MIUI blocked accessUse an official request or alternative methods
Support refuses to issue codeDevice blacklisted (stolen/lost)Provide check and data of the seller
The code is reset after the updateThe system generates new code when changing firmwareRepeat the procedure for obtaining the code again

Critical error: If you enter a 20-digit code more than 5 times in a row and receive the message "Device is locked", the device will be locked for 72 hours, in which case you only have to wait or contact the service center.

Alternative ways to unlock without a 20-digit code

If you can’t get the code, consider alternative unlock methods:

  • 🔄 Fastboot reset: suitable for devices with unlocked bootloader. Command: fastboot erase userdata Attention: deletes all data!
  • 📱 Use of the EDL-Mode: Requires an authorized Xiaomi account and a special cable.
  • 🛠️ Contact the service center: official Xiaomi centers can unlock the device under warranty.
  • 🔓 TestPoint bypass: the last resort for power users (the risk of bricking").

Most alternative methods require technical skills or specialized equipment, and if you are not confident in your abilities, you should consult a professional.

💡

The most reliable way to unlock is to request code through Xiaomi support, and alternative methods can cause data loss or device breakdown.

FAQ: Frequent questions about Xiaomi's 20-digit code

Can you create a 20-digit code yourself?
No, the code is generated by Xiaomi servers based on IMEI and account data. Any online code generators are a scam.
What to do if Xiaomi support is not met?
Repeat the request via another channel (e.g. Twitter or local office) and indicate on the ticket that the problem is urgent.
Can I use the code from another Xiaomi device?
No, the code is unique to each device and is tied to its IMEI, and trying to use someone else's code will lead to lockdown.
How do I know if my Xiaomi bootloader is unlocked?
Turn off the phone, then press Volume Down + Power to log into Fastboot. If there's Unlocked at the bottom of the screen, the bootloader is unlocked.
Will the 20-digit code reset after resetting?
Yes, with a full reset, the code can change. It is recommended to get a new code after the reset.