Windows環境下部署neo4j
部署
1. 下載windows環境下的安裝包neo4j-community-3.2.0-windows-chs-1.0.0.zip
網址:http://www.we-yun.com/index.php/blog/releases-56.html
2. 解壓,比如目錄為E:\neo4j
3.設定環境變數
變數名:NEO4J_HOME
變數值:E:\neo4j
再修改變數path,增加%NEO4J_HOME%\bin
4.檢視並編輯配置引數
%NEO4J_HOME%\conf\neo4j.conf
5.啟動
在DOS命令列視窗,切換到主目錄%NEO4J_HOME%\bin,執行:
neo4j.bat console
6. 開啟neo4j整合的瀏覽器
http://localhost:7474/
首先輸入命令: server connect
之後編寫Cypher命令,建立兩個節點和兩個關係:
CREATE (n:Person { name: 'Andres', title: 'Developer' }) return n; CREATE (n:Person { name: 'Vic', title: 'Developer' }) return n; match(n:Person{name:"Vic"}),(m:Person{name:"Andres"}) create (n)-[r:Friend]->(m) returnr; match(n:Person{name:"Vic"}),(m:Person{name:"Andres"}) create (n)<-[r:Friend]-(m) return r;
7. python程式設計
pip install neo4j-driver
8.在eclipse裡編寫程式並執行:
#
!/usr/bin/python
# -*- coding: utf-8 -*-
from neo4j.v1 import GraphDatabase
uri = "bolt://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "520"))
def cyphertx(cypher):
with driver.session() as session:
with session.begin_transaction() as tx:
tx.run(cypher)
cypher = """
create (Neo:Crew {name:'Neo'}),
(Morpheus:Crew {name: 'Morpheus'}),
(Trinity:Crew {name: 'Trinity'}),
(Cypher:Crew:Matrix {name: 'Cypher'}),
(Smith:Matrix {name: 'Agent Smith'}),
(Architect:Matrix {name:'The Architect'}),
(Neo)-[:KNOWS]->(Morpheus),
(Neo)-[:LOVES]->(Trinity),
(Morpheus)-[:KNOWS]->(Trinity),
(Morpheus)-[:KNOWS]->(Cypher),
(Cypher)-[:KNOWS]->(Smith),
(Smith)-[:CODED_BY]->(Architect)
"""
cyphertx(cypher)
9. 登入browser,執行查詢:
match(n) return n limit 25
來自:
http://www.cnblogs.com/ljhdo/archive/2017/05/19/5521577.html
http://blog.csdn.net/sweeper_freedoman/article/details/70189153?locationNum=3&fps=1