Connect
cypher-shell -u <user> -p <password>
Connect to localhost
Defaults to neo4j://localhost:7687. Leave -p out to be
prompted.
cypher-shell -a <uri>
Connect to another server
Schemes such as neo4j+s:// enable TLS. Env: NEO4J_URI.
cypher-shell -d <database>
Start in a given database
cypher-shell --access-mode read
Open a read-only session
cypher-shell --encryption true
Force an encrypted connection
Must match the server's TLS configuration.
cypher-shell --change-password
Change the neo4j password and exit
cypher-shell -v
Print the shell version
Environment variables
| Variable |
Replaces |
NEO4J_USERNAME |
-u |
NEO4J_PASSWORD |
-p |
NEO4J_ADDRESS |
-a |
NEO4J_DATABASE |
-d |
Script & output
cypher-shell "<cypher>"
Run one statement and exit
cypher-shell -f <file>
Run a Cypher file and exit
cypher-shell --format plain
Minimal output for scripts
cypher-shell --format verbose
Tables plus statistics
cypher-shell -P '{n: 3}'
Set a session parameter
Repeat -P for several parameters.
cypher-shell --fail-at-end
Report errors after the whole file
The default, --fail-fast, stops at the first error.
cypher-shell --non-interactive
Force non-interactive mode
cypher-shell --transaction-timeout <time>
Limit transaction time
Example: 10m. Needs a recent shell (2025.12 or later).
cypher-shell --log <file>
Write debug log to a file
Read
MATCH (n) RETURN n LIMIT <k>
Sample some nodes
MATCH (n:<Label>) RETURN n
Nodes with a label
MATCH (n:<Label> {<prop>: <value>})
RETURN n
Match by property
MATCH (a)-[r:<TYPE>]->(b) RETURN a, r, b
Follow a relationship type
WHERE n.<prop> > <value>
Filter matches
Also supports AND, OR, NOT, IN, IS NULL and STARTS WITH.
RETURN n.<prop> AS <alias>
Rename a returned value
RETURN DISTINCT n.<prop>
Remove duplicate rows
ORDER BY n.<prop> DESC
Sort the rows
SKIP <n> LIMIT <m>
Page through results
OPTIONAL MATCH (n)-->(m)
Match, or give null
MATCH (a)-[*1..3]->(b)
Paths of one to three hops
MATCH p = shortestPath((a)-[*]-(b))
Shortest path between two nodes
count(n), sum(n.<prop>), collect(n)
Aggregate rows
Non-aggregated RETURN columns become the grouping keys.
Write
CREATE (:<Label> {<prop>: <value>})
Create a node
CREATE (a)-[:<TYPE>]->(b)
Create a relationship
MATCH both nodes first, then CREATE between them.
MERGE (n:<Label> {<prop>: <value>})
Create only if missing
Match-or-create; avoids duplicates on reruns.
SET n.<prop> = <value>
Set a property
SET n += {<prop>: <value>}
Update several properties
REMOVE n.<prop>
Remove a property
DELETE r
Delete a relationship
DETACH DELETE n
Delete a node and its relationships
Plain DELETE fails while relationships remain.
MATCH (n) DETACH DELETE n
Wipe the whole graph
Irreversible. Large graphs need batching.
ON CREATE SET n.<prop> = <v>
Set only when MERGE creates
ON MATCH SET n.<prop> = <v>
Set only when MERGE matches