How do you create multiple databases on one server using neo4j? I have multiple clients, and I want to separate all client information into different database to avoid data leaks.
-
You can copy-paste the main folder of neo4j server. https://stackoverflow.com/a/58751637/3209523 – canbax Dec 20 '19 at 12:15
3 Answers
You need to have multiple Neo4j installations with a different port configurations in conf/neo4j.properties
and conf/neo4j-server.properties
.
Alternatively you might use some virtualization or container tool like http//docker.io for a more sophisticated approach.

- 39,465
- 6
- 87
- 97
-
13What's the logic behind this? Sure I'm still blinded by my knowledge of SQL but whats the reason for only having a single DB? – chuckjones242 Nov 28 '14 at 19:47
-
1what's wrong with having different processes for different things? – Stefan Armbruster Nov 29 '14 at 09:46
-
8@StefanArmbruster more efforts to create new db and support another ports/server instance – Stanislav Verjikovskiy Aug 28 '15 at 15:10
-
5So we need to make multiple copies of the full neo4j community directory ? One copy for each database graph ? Why is Neo4J not handling mutiple graphs like an RDBMS does for schemas ? – Stephane Aug 30 '15 at 11:02
-
Yes, use full copies. There's already a open ticket for this at https://github.com/neo4j/neo4j/issues/266. – Stefan Armbruster Aug 30 '15 at 20:44
-
2how do i make another neo4j installation? surely apt-get does not let you change the install location? – resgh Jun 19 '17 at 07:00
or add a special label
to each node for a client, e.g. :ClientName
.
or create a root node for each clients database, and always begin the querying at the first node.
in neo4j db, you can have separate subgraphs. if you do programm your code good, there should be no reason to have such leaks.

- 5,748
- 5
- 33
- 47
-
20The need to have a separate database is very real. For example in testing, you would not want to test against the main database that you are using for development (or production if someone is brave enough to do it) because each test runs with a fresh state of the database (ideally) – Tan Nguyen May 14 '15 at 07:59
-
3@TanNguyen If you develop/test on a production server I think you might have design issues. Cheers! – Boyan May 22 '15 at 20:17
-
8@Ash What I meant is to have 2 separate environments when testing and developing. It is obvious that testing in production is a big no no. Please read my comment careful before jumping to conclusion – Tan Nguyen May 23 '15 at 00:07
-
Yeah sorry if I sounded rude but you really should never come to such situations. Storing multi-domain data (say, with the label "namespace" approach) in one Neo4j database is completely fine (at least with me) since the db engine manages its indices very, very good. – Boyan May 24 '15 at 08:27
-
1@Ash it's a common use case when on single server you have prod and dev/test db with no impact on prod – Stanislav Verjikovskiy Aug 28 '15 at 15:13
-
I am interested to know of how a root node implementation might by like, cheers. I would appreciate some examples – Decebal Dec 20 '15 at 23:19
-
2@decebal hi decebal, its simple. attach all nodes from database A to one "root" node, and attach all nodes from database B to another root node. querying a dataset will have to always include the particular root node for which database you want to access. this is more-less a code based solution to distinguish standalone datasets in one neo4j server instance. – ulkas Jan 08 '16 at 09:41
-
also note, that a supernode with many relations (i remember having 200k and more relations few years ago, maybe the engine has been optimized to handle more these days) will slow querying. so this solution is ok for many, many sub datasets with ~100k nodes (ie 100k relations to the root node) at max. – ulkas Jan 08 '16 at 09:44
Update: Apr 11 2020 Recently (End of 2019, early March 2020) Neo4j has come up with supporting multiple database in same instance
You can manage multiple database using simple commands like below
:use system
:show databases
:create database exampleDB
:use eampleDB
Please read more about from here
PS: The multiple database feature is Enterprise edition/license only, not available for community :-(
as @stefan-armbruster has mentioned it might be good to use multiple Neo4j docker container instances for running multiple Databases
May be below docker compose file should be able to help u in doing this
version: '2'
services:
neo4j:
image: neo4j:latest
network_mode: host
restart: always
environment:
- NEO4J_AUTH: neo4j/neo4j
cap_add:
- SYS_RESOURCE
ports:
- "7474:7474"
- "7687:7687"
volumes:
- $HOME/neo4j/data:/data
Update: 23rd Dec 2020 if you need latest version of docker-compose, here below it is
version: '3.8'
services:
neo4j:
image: neo4j:4.2
restart: always
ports:
- '7474:7474'
- '7473:7473'
- '7687:7687'
volumes:
- ./data:/data
- ./logs:/logs
- ./import:/import
- ./plugins:/plugins
environment:
- NEO4J_AUTH=neo4j/neo4j
once you have saved the above to a docker-compose.yml, run below command
docker-compose up
if you want to run in background
docker-compose up -d
Now you should be able to access the database as http://localhost:7474
, if you are using docker-machine, you will have to use the docker-machine IP address to access the database
By maintaining multiple docker-compose files with different ports in them, you can maintain multiple database, this is not just for neo4j, you can do it for any type of DBs (Mongo, Redis, RabbitMQ etc.,)
for specifying different docker compose file, try below command
docker-compose -f <your docker compose file name>

- 3,176
- 1
- 22
- 20
-
You can also refer this useful link https://medium.com/@slavahatnuke/neo4j-node-js-docker-docker-compose-fdc1cc9cf405#.syy5fgqbu – Basav Dec 09 '16 at 04:55