Magento 2 How to reset admin password using CLI / Command Prompt / Terminal in Linux
Let's see how we can reset Magento 2 admin password in Linux using CLI / command prompt or terminal.Getting the cryptographic saltMagento 2 passwords are stored after scrambling with the cryptographic salt which is defined in the app\etc\env.phpSo first we need to copy that.open the file app\etc\env...
Let's see how we can reset Magento 2 admin password in Linux using CLI / command prompt or terminal.
- Getting the cryptographic salt
Magento 2 passwords are stored after scrambling with the cryptographic salt which is defined in the app\etc\env.php
So first we need to copy that.- open the file app\etc\env.php
- Goto crypt section and copy the key value. ( check the image below)

- Preparing the SQL
- In below sql query,
- Replace xxxxxxx with the crypt key from step 1
- Replace YourNewPassword with your new password.
- Replace admin with your admin username ( if its changed from admin)
- if you your magento 2 installation uses a table_prefix , please add that infront ofadmin_user
UPDATE admin_userSET password = CONCAT(SHA2('xxxxxxxYourNewPassword', 256), ':xxxxxxx:1') WHERE username = 'admin';
- In below sql query,
- Now you have two options to execute this query against your database.
- Via CLI/command prompt/terminal
- Login to Mysql using the below command
mysql -u root -p ( enter mysql password when prompted - select your database
use your_database_name; - Paste the query and press enter
- Login to Mysql using the below command
- Via PHPMyAdmin
Paste the query in the PHP myAdmin SQL tab and execute.
- Via CLI/command prompt/terminal
- Log in to the Magento admin using the new password! that's it!
[/vc_column_text][/vc_column][/vc_row]
Related Articles
WP E-commerce Trends: Sri Lankan Exports 2026
Discover the top 2026 WordPress e-commerce trends for Sri Lankan SMBs exporting globally. Boost sales with AI, AR, and sustainable practices.
Mastering E-Commerce in Sri Lanka: The Definitive Business Guide for 2026
The digital marketplace has fundamentally reshaped how Sri Lankan enterprises connect with customers both locally and globally. As we navigate through 2026, e-commerce has evolved from a supplementary sales channel into the primary engine driving business growth across the nation. With Sri Lanka's e...
Emerging Client Needs: Localized Payments for Sri Lankan DTC Brands Using FriMi and Dialog Axiata
The Rise of Sri Lankan DTC and the Local Payment Gap
Multi-Currency WooCommerce for Sri Lankan SMEs | Cross-Border Trade
The Global Opportunity: Why Multi-Currency is a Game-Changer for Sri Lankan SMEs