As a developer you’re always going to need a login account for a WordPress website whether it’s for local testing or maintenance of a live website.

If you’ve set up your own WordPress website it’s likely that you already created an admin account but what if you’ve been brought in to an existing client project? In order to get set up you’ll probably request a copy of the WordPress theme files and the database to test out functionality locally.

Registering for an administrator account through the login page is not an option either as the administrator account must be created by an existing user with the same permissions. It’s very common to disable the account registration part of the website anyway as this can be a security risk.

Here are some examples of where creating an account would be problematic:

  1. The copy of the database doesn’t contain a login account that you can use
  2. You’ve forgotten your password or username and can’t login
  3. Creating a login directly in the database is not straightforward/possible
  4. No one is around to give you a login username/password

With the CLI you can create an account very quickly and easily.

Using the WordPress CLI


The following command can be run on a terminal either locally or connected remotely with SSH. The WP-CLI must be installed first.

wp user create username --role=administrator

Where username is something like anthony

Once the command above is run, there may be some warnings or errors displayed but at the bottom there will be a confirmation message with a new password like so

Success: Created user 2.
Password: 123456789abcdef

Make sure you store the password securely. I recommend 1Password. You can then login to your site with the username you typed above with the password.

When using Local by Flywheel

  1. In Local, right-click on a site and click “connect via SSH”
  2. Run the above command
  3. Save the generated password

When you can’t SSH/WP CLI is not installed

If you can’t SSH , you could execute a shell script

  1. Create a blank file called something like (see below)
  2. Set permissions to execute the file (chmod +x
  3. Run the file ./
wp user create username --role=administrator --user_pass=<password>

Notice I have included the user_pass in this case- this is because once the script is run, there’s no way of seeing the generated password.

Once you’ve run the above script, you can login with the credentials written in the bash script. If the script is installed on a server you must delete it so other commands can’t be run in the script.

Back to blog