Today we are going to look at how to unlock Magento 2 admin user via command line. As an admin user or a developer, we use to login to the admin panel very frequently and there could be some unsuccessful login attempts that could possibly have our admin panel account user to get temporarily disabled by the Magento 2 for security purposes.
Temporarily disabled admin user accounts can be unlocked using the CLI command. There are many Magento 2 CLI commands in the bin/magento and admin:user:unlock comes in handy for this purpose.
Admin Error Message for Locked User:
Whenever your Magento 2 admin user account is locked, you would see the following error message when trying to login to the admin panel:

Unlock Magento 2 Admin User via Command Line:
You will need to connect to the server via a terminal and navigate to the Magento 2 root directory.
Syntax for Magento 2 CLI command to unlock user:
php bin/magento admin:user:unlock username
Once you are in the Magento 2 root directory, execute the above command by replacing the username with your actual Magento 2 admin username like the following example:
php bin/magento admin:user:unlock sparkdeveloper
Executing the unlock command would display a message like the following:
The user account "sparkdeveloper" has been unlocked
If the user account is already unlocked or not temporarily disabled, it would display a message like the following:
The user account "sparkdeveloper" was not locked or could not be unlocked
Thus we unlocked a temporarily disabled admin user.
Admin User Unlock Help:
If you would like to know more information regarding the usage of the admin:user:unlock command, you can execute the following help command and it will display more useful information regarding the usage of the user unlock command:
php bin/magento admin:user:unlock --help
Description:
Unlock Admin Account
Usage:
admin:user:unlock <username>
Arguments:
username The admin username to unlock
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
This command unlocks an admin account by its username.
To unlock:
bin/magento admin:user:unlock username
If you found this article helpful, kindly bookmark it and share it with you fellow mates and do follow our social media handles.