解压到/opt/下
tar zxvf /tmp/neo4j-community-3.4.10-unix.tar.gz -C /opt/
cd /opt/neo4j-community-3.4.10/
cd bin/
./neo4j start
./neo4j status
./neo4j-shell -path /opt/neo4j-community-3.4.10/
建议使用cypher-shell
./cypher-shell
username: neo4j
默认密码neo4j
password: *****
Connected to Neo4j 3.4.10 at bolt://localhost:7687 as user neo4j.
Type :help for a list of available commands or :exit to exit the shell.
Note that Cypher queries must end with a semicolon.
neo4j>
需要修改密码
CALL dbms.changePassword('test')
neo4j> match (n) return n;
0 rows available after 10 ms, consumed after another 1 ms
neo4j> create (p:Person {name:'zhangsan'}) return p;
+------------------------------+
| p |
+------------------------------+
| (:Person {name: "zhangsan"}) |
+------------------------------+
1 row available after 172 ms, consumed after another 0 ms
Added 1 nodes, Set 1 properties, Added 1 labels
neo4j> match (n) return n;
+------------------------------+
| n |
+------------------------------+
| (:Person {name: "zhangsan"}) |
+------------------------------+
1 row available after 2 ms, consumed after another 1 ms
neo4j> create (p:Person {name:'lisi'}) return p;
+--------------------------+
| p |
+--------------------------+
| (:Person {name: "lisi"}) |
+--------------------------+
1 row available after 26 ms, consumed after another 0 ms
Added 1 nodes, Set 1 properties, Added 1 labels
neo4j> match (p:Person {name:'lisi'}), (q:Person {name:'zhangsan'}) create (p)-[r:Friend {name:'is_friend'}]->(q) return r;
+-------------------------------+
| r |
+-------------------------------+
| [:Friend {name: "is_friend"}] |
+-------------------------------+
1 row available after 276 ms, consumed after another 0 ms
Created 1 relationships, Set 1 properties
neo4j> match (n)-[*]-(p) return n,p;
+-------------------------------------------------------------+
| n | p |
+-------------------------------------------------------------+
| (:Person {name: "lisi"}) | (:Person {name: "zhangsan"}) |
| (:Person {name: "zhangsan"}) | (:Person {name: "lisi"}) |
+-------------------------------------------------------------+
2 rows available after 130 ms, consumed after another 21 ms
neo4j>
使用正则匹配:
neo4j> match (n)-[r:Friend]-(p) where p.name=~'li.*' return n,p,r.name,p.name;
+--------------------------------------------------------------------------------+
| n | p | r.name | p.name |
+--------------------------------------------------------------------------------+
| (:Person {name: "zhangsan"}) | (:Person {name: "lisi"}) | "is_friend" | "lisi" |
+--------------------------------------------------------------------------------+
1 row available after 34 ms, consumed after another 1 ms
neo4j> match (n)-[r:Friend]-(p) where p.name=~'li.*' and type(r)=~"F.*" return n,p,r.name,p.name;
+--------------------------------------------------------------------------------+
| n | p | r.name | p.name |
+--------------------------------------------------------------------------------+
| (:Person {name: "zhangsan"}) | (:Person {name: "lisi"}) | "is_friend" | "lisi" |
+--------------------------------------------------------------------------------+
1 row available after 82 ms, consumed after another 0 ms