Neo4j Admin and Neo4j CLI
Introduction
neo4j-admin
and neo4j
are command-line tools for managing and administering a Neo4j DBMS.
Both are installed as part of the product and can be executed with a number of commands.
The neo4j
commands are equivalent to the most important commands in the neo4j-admin
server category.
Both neo4j-admin
and neo4j
commands support the --help
option, which prints the command’s usage and options, and the --version
option, which prints the version of the command.
All admin command options can also be provided in a file and passed to the command using the @
prefix.
This is useful when the command line becomes too long to manage.
For example, neo4j-admin database import full @/path/to/your/<args-filename> mydb
.
For more information, see Picocli → AtFiles official documentation.
All admin commands must be invoked with the same user as Neo4j runs as. This guarantees that Neo4j will have full rights to start and work with the database files you use. |
The neo4j-admin
tool
The neo4j-admin
command-line tool is located in the bin directory.
General synopsis
neo4j-admin
has the following general synopsis:
neo4j-admin [category] [command] [subcommand]
neo4j-admin
commands per category
All administration commands, except for help
and version
, are organized into the following three categories:
-
dbms
- DBMS-wide (for single and clustered environments) administration tasks -
server
- server-wide administration tasks -
database
- database-specific administration tasks
Category | Command | Description |
---|---|---|
|
|
Sets the default admin user when no roles are present. |
|
Sets the initial password of the initial admin user ( For details, see Set an initial password. |
|
|
Removes and archives the cluster state of the |
|
|
|
Starts DBMS server in the console. |
|
Displays the server ID of an instance. The server ID can be used to specify a server in Cypher commands. |
|
|
Accept the license agreement. Possible options are |
|
|
Prints recommendations for Neo4j heap and page cache memory usage. For details, see Memory recommendations. |
|
|
Migrates server configuration from the previous major version. |
|
|
Produces a ZIP/TAR of the most common information needed for remote assessments. For details, see Neo4j Admin report. |
|
|
Restarts the server daemon. |
|
|
Starts the server as a daemon. |
|
|
Gets the status of the server. |
|
|
Stops the server daemon. |
|
|
Removes cluster state data from a stopped Neo4j server. For details, see Unbind a Neo4j cluster server. |
|
|
Performs configuration validation without starting the server. |
|
|
A command whose subcommands can be used to install, uninstall, and update Neo4j as a Windows service. |
|
|
|
Aggregates a chain of backup artifacts into a single artifact. |
|
Performs an online backup from a running Neo4j enterprise server. |
|
|
Checks the consistency of a database. For details, see Consistency checker. |
|
|
Copies a database and optionally applies filters. For details, see Copy a database store. |
|
|
Dumps a database into a single-file archive. |
|
|
Imports a collection of CSV files. For details, see Import. |
|
|
Prints information about a Neo4j database store. For details, see Display store information. |
|
|
Loads a database from an archive created with the |
|
|
Migrates a database from one store format to another or between versions of the same format. |
|
|
Restores a backed up database. |
|
|
Pushes a local database to a Neo4j Aura instance. For details, see Upload to Neo4j AuraDB. |
The neo4j
tool
The neo4j
command-line tool is located in the bin directory.
neo4j
commands
The command is an alias for the most important commands in the neo4j-admin server
category.
neo4j command |
Equivalent neo4j-admin command |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Version command
Version can be obtained by invoking the version
command, --version
command option, or its short alternative -V
, on the root level of both neo4j
and neo4j-admin
commands.
For example, neo4j --version
, neo4j-admin -V
, neo4j-admin version
, or neo4j version
.
Help command
Help can be obtained by invoking the help
command, --help
command option, or its short alternative -h
, with both neo4j
and neo4j-admin
commands.
--help
and -h
options can be invoked on any level, namely root, category, command, and subcommand.
For example, neo4j --help
, neo4j [command] -h
, neo4j-admin -h
, neo4j-admin [category] --help
, or neo4j-admin [category] [command] [subcommand] -h
.
The help command can be invoked on any level except the last one, which means command-level for commands that do not have subcommands or subcommand level for commands with subcommands.
The help command also accepts a parameter.
For example, neo4j help
, neo4j-admin help
, neo4j-admin [category] help
, neo4j-admin help [category]
, neo4j help [command]
, or neo4j-admin [category] [command ] help [subcommand]
.
Limitations
When using both a multi-value option and a positional parameter, the multi-value option is "greedy" and pulls in the next positional parameter via its convertor. This is a limitation of the underlying library, Picocli, and is not specific to Neo4j Admin. See Picocli → Variable Arity Options and Positional Parameters official documentation for more information.
Configuration
Administration operations use the configuration specified in the neo4j.conf file. Sharing configuration between the DBMS and its administration tasks makes sense as most settings are the same. In some cases, however, it is better to override some settings specified in neo4j.conf by configuring the tasks (instead of updating the config settings in the neo4j.conf file) because administration tasks generally use fewer resources than the DBMS. For instance, if the page cache of your DBMS is configured to a very high value in neo4j.conf, and you want to override this because the admin tasks like backup do not need so much memory, you provide configuration for the admin tasks instead of updating the page cache setting in the neo4j.conf file.
There are several options for overriding settings specified in the neo4j.conf file using administration tasks:
-
--additional-config
option — almost all administration commands support the--additional-config
option, which you can use to provide a path to a file with additional configuration. -
neo4j-admin.conf — a configuration file located in the same directory as the
neo4j.conf
file, which you can use to provide administration-task-specific settings. -
Some commands also support a command-specific configuration file. Such files are also looked for in the same directory as the neo4j.conf file. The following table lists command-specific configuration files:
Table 3. Command-specific configuration files Command Configuration file neo4j-admin database backup
neo4j-admin-database-backup.conf
neo4j-admin database check
neo4j-admin-database-check.conf
neo4j-admin database copy
neo4j-admin-database-copy.conf
neo4j-admin database dump
neo4j-admin-database-dump.conf
neo4j-admin database import
neo4j-admin-database-import.conf
neo4j-admin database load
neo4j-admin-database-load.conf
neo4j-admin database migrate
neo4j-admin-database-migrate.conf
neo4j-admin database restore
neo4j-admin-database-restore.conf
All four configuration sources are optional and settings for administration commands are resolved from them with the following descending priority:
-
--additional-config
option -
command-specific configuration file
-
neo4j-admin.conf
-
neo4j.conf
The commands for launching the DBMS, |
Environment variables
Neo4j Admin can also use the following environment variables:
Environment variable | Description |
---|---|
|
Set to anything to enable debug output. |
|
Neo4j home directory. |
|
Path to the directory that contains neo4j.conf. |
|
Set JVM maximum heap size during command execution. Takes a number and a unit, for example, 512m. |
|
Additional JVM arguments. |
If set, HEAP_SIZE
and JAVA_OPTS
override all relevant settings specified in the configuration file.
Exit codes
When neo4j
and neo4j-admin
finish as expected, they exit with code 0
.
A non-zero exit code means something undesired happened during command execution.
Exit code | Description |
---|---|
|
Successful execution. |
|
The command failed to execute. |
|
The command failed to execute because the database is not running. |
|
The command was invoked with incorrect options/parameters. See the printed usage for details. |
|
An exception was thrown, not handled otherwise. |
The non-zero exit code can contain further information about the error, for example, see the backup
command’s exit codes.
Command-line completion
From 5.4 onwards, Neo4j supports command-line completion.
-
For Unix-based systems, the tab completion applies to the
neo4j
andneo4j-admin
command line interfaces in terminals such as Bash and ZSH. -
For RPM and DEB packaged installations, the necessary files are automatically installed in
bash-completion
. -
For tarball installations, the files are located in the bin/completion/ directory with detailed instructions for manual installation.