How to reset / clear / delete neo4j database?

Somnath Muluk picture Somnath Muluk · Apr 26, 2014 · Viewed 63k times · Source

We can delete all nodes and relationships by following query.

MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r

But newly created node get internal id as ({last node internal id} + 1) . It doesn't reset to zero.

How can we reset neo4j database such as newly created node will get id as 0?

From 2.3, we can delete all nodes with relationships,

MATCH (n)
DETACH DELETE n

Answer

Stefan Armbruster picture Stefan Armbruster · Apr 26, 2014

Shut down your Neo4j server, do a rm -rf data/graph.db and start up the server again. This procedure completely wipes your data, so handle with care.