root@node11:~# cat /etc/lsb-release 
 DISTRIB_ID=Ubuntu
 DISTRIB_RELEASE=20.04
 DISTRIB_CODENAME=focal
 DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
 root@node11:~# cat /etc/issue
 Ubuntu 20.04.6 LTS \n \l
1.安装jdk
 java 1.8.xx版本对应neo4j 3.xx版本
 jdk 11版本对应neo4j 4.xx版本,此次安装4.4.36
 apt install openjdk-11-jdk
 2.添加资源库
 (1)wget -O - https://debian.neo4j.com/neotechnology.gpg.key | apt-key add -
 (2)echo 'deb https://debian.neo4j.com stable 3.5' | tee /etc/apt/sources.list.d/neo4j.list
 (当前使用:echo 'deb https://debian.neo4j.com stable 4.4' | tee /etc/apt/sources.list.d/neo4j.list)
 (3)apt-get update
 3. 安装社区版neo4j:
 apt-get install neo4j
 4. 此时可查看其运行状态:
 systemctl status neo4j
 5. 设置为在系统重新启动时启动:
 (1)systemctl enable neo4j
 (2)systemctl start neo4j
 *(3)systemctl status neo4j
 6. 连接和配置neo4j。
 (1)测试连接到数据库:
 cypher-shell。
 默认neo4j 用户名和 neo4j 密码。
 :exit
 提示修改密码。
 ~$ cypher-shell
 username: neo4j
 password: neo4j
 neo4j> CALL dbms.changePassword('yournewpassword');
 0 rows available after 24 ms, consumed after another 0 ms
 neo4j> 
7. 使用neo4j。
root@node11:~# cypher-shell -u neo4j -p xxxx.
 Connected to Neo4j using Bolt protocol version 4.4 at neo4j://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@neo4j> 
 neo4j@neo4j> show databases;
 +---------------------------------------------------------------------------------------------------------------------------------+
 | name     | aliases | access       | address          | role         | requestedStatus | currentStatus | error | default | home  |
 +---------------------------------------------------------------------------------------------------------------------------------+
 | "neo4j"  | []      | "read-write" | "localhost:7687" | "standalone" | "online"        | "online"      | ""    | TRUE    | TRUE  |
 | "system" | []      | "read-write" | "localhost:7687" | "standalone" | "online"        | "online"      | ""    | FALSE   | FALSE |
 +---------------------------------------------------------------------------------------------------------------------------------+
2 rows
 ready to start consuming query after 15 ms, results consumed after another 4 ms
登录到 neo4j后,就可以通过命令行进行查询以及将实体和关系添加到数据库中了。
neo4j>
密码输入错误会提示:
username: neo4j
 password: *****
 The client is unauthorized due to authentication failure.
 8.关闭和启动。
 systemctl restart neo4j
 systemctl start neo4j
 systemctl stop neo4j
 9. 新建和切换数据库。
社区版不支持用create database yourdbname创建。
社区版只可同时打开一个数据库,但可以存在多个数据库。
在/etc/neo4j/neo4j.conf中做如下修改:
#dbms.default_database=neo4j
dbms.default_database=neo4yours
对于社区版,此修改可实现数据库的切换,每次切换均需修改,use database命令不可用。
关闭neo4j并重启,neo4j会自动创建neo4yours:
 systemctl restart neo4j
10. Web Browser。
服务处于开启状态:
 http://localhost:7474
Start querying
修改root@node11:~# cat /etc/neo4j/neo4j.conf|grep listen
 dbms.default_listen_address=0.0.0.0
 重启库后,可以使用浏览器ip地址连接:
 systemctl restart neo4j
 http://192.168.207.11:7474/
root@node11:~# cat /etc/neo4j/neo4j.conf|grep database
 # The name of the default database
 #dbms.default_database=neo4j
 # Whether or not any database on this instance are read_only by default.
 # If false, individual databases may be marked as read_only using dbms.database.read_only.
 # If true, individual databases may be marked as writable using dbms.databases.writable.
 #dbms.databases.default_to_read_only=false
 # full access to the database through unsupported/insecure internal APIs.
 # the process, before starting the database. This reduces memory
 root@node11:~# cat /etc/neo4j/neo4j.conf|grep listen
 dbms.default_listen_address=0.0.0.0
 # port for each connector, by setting their individual listen_address.
 #dbms.connector.bolt.listen_address=:7687
 #dbms.connector.http.listen_address=:7474
 #dbms.connector.https.listen_address=:7473
 11. Desktop。
服务处于开启状态:
bolt://localhost:7687
Connect -> Open -> Start querying
12. 试用。
match(n) return n
13. Python 连接、清空、导入数据。
from py2neo import Graph, Node, Relationship,NodeMatcher
graph = Graph('http://localhost:7474', auth=('neo4j', '********'))
清空数据库:
graph.delete_all()
导入数据:
s_node=Node("实体类型", name=v1)
 e_node=Node("实体类型", name=v2)
 r=Relationship(s_node, v3, e_node)
 graph.merge(s_node, "实体类型", "name")
 graph.merge(e_node, "实体类型", "name")
 graph.merge(r, "Label", "name")
14.相关参考:
Neo4j在Ubuntu 20.04上安装、配置以及Python连接使用 - Neo4j
neo4j导出导入
Neo4j的使用+导入导出csv文件
neo4j进阶操作(四)neo4j导入csv,使用load导入csv文件进入neo4j




















