There might be a scenario where you have lost or forgotten the Nopcommerce admin password due to any reasons. But don't need to worry because, in this tutorial, we will guide you on how you can reset your forgotten password of Nopcommerce admin. Here, we have mentioned two options, how can you regain your access to Nopcommerce admin. You must have MSSQL database user credentials to handle these steps.
IMP Note: This article will help you to reset the admin password of NopCommerce 4.1. If you have another version, there might be slight changes in steps.
Option 1: How to Change the Password of Existing Administrator Account?
- Log into your SQL Server Management Studio with the NopCommerce DB user credentials.
- Click on the New Query and execute the below query inside the window. Ensure that you replace the admin_user_email_address with your actual email address.
SELECT Id FROM dbo.Customer
WHERE Username = 'admin_user_email_address'
- The above query will give you the user ID of the admin email address. You need to remember this ID to run the future query.
- Again click on the New Query and execute the below T-SQL statement. Ensure that you replace the yournewpassword with the new password you want to reset and change the ID with the ID we have received from the above query.
SET PasswordSalt = '', PasswordFormatId = 0, Password = 'yournewpassword'
WHERE CustomerId = Id
- You have successfully changed the password of your Nopcommerce admin. Go to (Login >> Customers >> Customers >> Edit >> Change Password) and instantly change your password that we have just reset.
- Return to the SQL Management Studio and execute the below command. Replace the ID with the CustomerID as we have received in the first query. This command will delete the plain text password. It will help against account compromised issues.
DELETE FROM dbo.CustomerPassword
WHERE CustomerId = Id AND PasswordFormatId = 0
Option 2: How to Create a New User and Grand Administrative Privileges to it?
- Register a New User. To do this, go to the customer registration page and create a new account.
- Access your database using SQL Management Studio.
- Click on the New Query and execute the below T-SQL command. Replace the email_user with your new email account that you have registered in step 1.
SELECT Id FROM dbo.Customer
WHERE Username = 'email_user'
- The above query will give you the ID of the newly registered user. Run the below query using the ID that we have received.
INSERT INTO dbo.Customer_CustomerRole_Mapping (Customer_Id, CustomerRole_Id)
VALUES (Id, 1)
- Login to your Nopcommerce using the newly registered account, and you will find that it has administrative privileges. Using this account, you can change the password of your Nopcommerce Admin, which password you lost. Now, you can remove the newly created user, or you can keep using it.