Is there a tool to dump a Neo4j graph as Cypher and re-load it from Cypher?

和自甴很熟 提交于 2019-12-22 04:29:18

问题


Everyone familiar with MySQL has likely used the mysqldump command which can generate a file of SQL statements representing both the schema and data in a MySQL database. These SQL text files are commonly used for many purposes: backups, seeding replicas, copying databases between installations (- copy prod DBs to staging environments etc) and others.

Is there a similar tool for Neo4j that can dump an entire graph into a text file of Cypher statements, that when executed on an empty database would reconstruct the original data?

Thanks.


回答1:


In neo4j version 2 (e.g. 2.0.0M3), using neo4j-shell, you can use the command

dump

which will create the cypher statements (pretty much like mysqldump would do. To read in the file you can use

cat dump.cql | neo4j-shell




回答2:


Cypher is just a query language for Neo4J just as SQL is for MySQL or other relational databases. If you wish to transfer the db, then you just need to copy the folder containing the database files. Simple.

For example my folder simple-graph contains all the db files. Just copy the folder and store it at some other location. You can directly start using it as:

GraphDatabaseServiceraphDb = new EmbeddedGraphDatabase(DB_PATH);//DB_PATH is path to the new location


来源:https://stackoverflow.com/questions/17871572/is-there-a-tool-to-dump-a-neo4j-graph-as-cypher-and-re-load-it-from-cypher

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!