neo4j-shell使用

步骤:

  1. 首先修改neo4j.conf配置文件,必须要修改配置后可以使用neo4j-shell。
  2. 启动Neo4j数据库。
  3. 使用 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

 
原文地址:https://www.cnblogs.com/kwzblog/p/14107315.html