图形数据库neo4j的安装使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_29493353/article/details/85329957

1.安装

ubutun:

wget -O - https://debian.neo4j.org/neotechnology.gpg.key | sudo apt-key add -
echo 'deb https://debian.neo4j.org/repo stable/' | sudo tee /etc/apt/sources.list.d/neo4j.list
sudo apt-get update
sudo apt-get install neo4j

centos:
cd /tmp
wget http://debian.neo4j.org/neotechnology.gpg.key
rpm --import neotechnology.gpg.key

cat <<EOF>  /etc/yum.repos.d/neo4j.repo
[neo4j]
name=Neo4j Yum Repo
baseurl=http://yum.neo4j.org/stable
enabled=1
gpgcheck=1
EOF

yum install neo4j

2.配置neo4j.conf

将listen_address配置上内网ip,否则其他机器浏览器访问不了网页

dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL
dbms.connector.bolt.listen_address=192.168.0.31:7687

# HTTP Connector. There can be zero or one HTTP connectors.
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=192.168.0.31:7474

# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=true
dbms.connector.https.listen_address=192.168.0.31:7473

3.shell客户端访问

可能先要初始化密码:

neo4j-admin set-initial-password qwerasd

其中bolt为一种网络协议(address不设置的话直接localhost)

 cypher-shell -a bolt://192.168.0.31:7687 -u neo4j -p qwerasdf

4.python通过http访问

"Authorization":"bmVvNGo6cXdlcmFzZGY=" 这个请求头参数用于认证

生成规则为 user:passwd 的base64

import urllib2,json

data = {"statements":[{"statement":"create (xiaopengfi:Person{name:\"xiaopengfei\",born:1992})"}]}
data = json.dumps(data)
header = {"Authorization":"bmVvNGo6cXdlcmFzZGY=","Accept":"application/json; charset=UTF-8","Content-Type":"application/json"}
req = urllib2.Request(url="http://192.168.0.31:7474/db/data/transaction/commit", data=data, headers=header)
resp = urllib2.urlopen(req)
print resp.read()

官网文档:https://neo4j.com/docs/operations-manual/3.2/

猜你喜欢

转载自blog.csdn.net/qq_29493353/article/details/85329957