步驟:
- 首先修改
neo4j.conf配置文件,必須要修改配置后可以使用neo4j-shell。 - 啟動Neo4j數據庫。
- 使用 neo4j-shell
1. 修改neo4j.conf配置文件
# 修改233行,去掉前面的#,允許使用neo4j-shell,類似於mysql 命令行之類的 # Enable a remote shell server which Neo4j Shell clients can log in to. dbms.shell.enabled=true # 修改235行,去掉#,設置連接neo4j-shell的端口,一般都是localhost或者127.0.0.1,這樣安全,其他地址的話,一般使用https就行 # The network interface IP the shell will listen on (use 0.0.0.0 for all interfaces). dbms.shell.host=127.0.0.1 # 修改237行,去掉#,設置neo4j-shell端口,端口可以自定義,只要不和其他端口沖突就行 # The port the shell will listen on, default is 1337. dbms.shell.port=1337
2 啟動Neo4j數據庫
重啟: ./neo4j restart
3 使用neo4j-shell
(base) [root@localhost bin]# (base) [root@localhost bin]# ./neo4j-shell Welcome to the Neo4j Shell! Enter 'help' for a list of commands. Please note that neo4j-shell is deprecated and to be replaced by cypher-shell. NOTE: Remote Neo4j graph database service 'shell' at port 1337 neo4j-sh (?)$ match (n) return count(n); +----------+ | count(n) | +----------+ | 413590 | +----------+ 退出: neo4j-sh (?)$ exit
連接指定ip host的Neo4j
./neo4j-shell -host 192.168.3.150 -port 1337 -name shell
批量執行cql
創建test.cql文件:
merge(d:測試{name:"kwz"}) return d;
merge(d:測試{name:"da"}) return d;
merge(d:測試11{name:"kwz"}) return d;
執行:./neo4j-shell -file ../cql_file/test.cql > ../cql_file/re.txt
