Create, edit, or unlock a Magento administrator account
First steps
-
Log in to the Magento server as, or switch to, a user who has permissions to write to the Magento file system. One way to do this is to switch to the Magento file system owner.
If you use the bash shell, you can also use the following syntax to switch to the Magento file system owner and enter the command at the same time:
su <Magento file system owner> -s /bin/bash -c <command>
If the Magento file system owner does not allow logins you can do the following:
sudo -u <Magento file system owner> <command>
-
To run Magento commands from any directory, add
<your Magento install dir>/bin
to your systemPATH
.Because shells have differing syntax, consult a reference like unix.stackexchange.com.
bash shell example for CentOS:
export PATH=$PATH:/var/www/html/magento2/bin
You can also run the commands in the following ways:
cd <your Magento install dir>/bin
and run them as./magento <command name>
php <your Magento install dir>/bin/magento <command name>
<your Magento install dir>
is a subdirectory of your web server's docroot. Need help locating the docroot? Click here.
In addition to the command arguments discussed here, see Common arguments.
Prerequisites
Before you can use this command, you must do all of the following:
- Create the deployment configuration
- Enable at minimum the Magento_Authorization and Magento_User modules
- Create the Magento database schema
The simplest way to create the database is to use the command magento setup:upgrade
.
Create or edit an administrator
Use this command to create a new administrator or to edit an existing administrator. If you’re editing an administrator, only the first name, last name, and password can be edited.
Command usage:
magento admin:user:create [--<parameter_name>=<value>, ...]
Where the following table defines parameters and values:
Name | Value | Required? |
---|---|---|
--admin-firstname |
Magento administrator user's first name. |
Yes |
--admin-lastname |
Magento administrator user's last name. |
Yes |
--admin-email |
Magento administrator user's e-mail address. |
Yes |
--admin-user |
Magento administrator user name. |
Yes |
--admin-password |
Magento administrator user password. The password must be at least 7 characters in length and must include at least one alphabetic and at least one numeric character. We recommend a longer, more complex password. Enclose the entire password string in single quotes. For example, |
Yes |
Unlock an administrator account
Use this command to unlock the account of an administrator that was locked, typically because of multiple incorrect login attempts.
magento admin:user:unlock {user name}
You must specify the administrator’s user name. Example:
magento admin:user:unlock admin
The user account "admin" has been unlocked
If the account is either not unlocked or if there was a problem, the following message displays:
The user account "admin" was not locked or could not be unlocked
Verify the user is an administrator, the user is active, and that the account is currently locked. To view the list of locked users in the Admin, log in as an administrator and click System > Permissions > Locked Users.
If the account doesn’t exist, the following message displays:
Couldn't find the user account "bob"
Related topics
- Installing the Magento software using the command line
- Remove sample data modules or update sample data
- Enable or disable modules
- Display or change the Admin URI
- Uninstall modules
- Create or update the deployment configuration
- Enable or disable maintenance mode
- Create the Magento database schema
- Update the Magento database schema and data
- Configure the store
- Back up and roll back the file system, media, and database
- Uninstall themes
- Uninstall language packages
- Uninstall the Magento software
- Update the Magento software
- Reinstall the Magento software