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
The neo4j-admin dbms set-initial-password has the following syntax:
neo4j-admin dbms set-initial-password [-h] [--expand-commands] [--verbose] [--require-password-change[=true|false]]
[--additional-config=<file>] <password>
Parameters
| Parameter | Description |
|---|---|
|
Options
The neo4j-admin dbms set-initial-password command has the following options:
| Option | Description | Default |
|---|---|---|
|
Configuration file with additional configuration. |
|
|
Allow command expansion in config value evaluation. |
|
|
Show this help message and exit. |
|
|
Require the user to change their password on first login. |
|
|
Enable verbose output. |
|
1. See Neo4j Admin and Neo4j CLI → Configuration for details.
| ||
Example
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., Prompt for password using
whiptail
Prompt for password using
dialog
|