Set an initial password

You can use the set-initial-password command of neo4j-admin to define the password for the native user neo4j. If not set explicitly, the password defaults to neo4j and must be changed at first login. This command is intended to be used only once, before the first startup of the database.

The default minimum password length is 8 characters. To change it, use the dbms.security.auth_minimum_password_length configuration setting.

Syntax

neo4j-admin dbms set-initial-password <password> [--require-password-change]

Usage

You can set the password for the native neo4j user before starting the database for the first time.
For example, to set the password to mySecretPassword, run the following command in your terminal:

neo4j-admin dbms set-initial-password mySecretPassword

To enforce a password change at first login, use the --require-password-change flag. This is particularly useful when setting a temporary password during initial setup.

For security reasons, it is not recommended to pass passwords as command-line arguments to avoid them being stored in the command-line history. One way to achieve this is by using Bash scripting (e.g., whiptail or dialog) to prompt for the password securely:

Prompt for password using whiptail
neo4j-admin dbms set-initial-password "$(whiptail --passwordbox "Enter password" 10 50 2>&1 >/dev/tty)"
Prompt for password using dialog
neo4j-admin dbms set-initial-password "$(dialog --passwordbox "Enter password" 10 50 2>&1 >/dev/tty)"