当前位置: 首页 > news >正文

Neo4j在Ubuntu 20.04上安装

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


相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 绿色物流:TMS在节能减排中的角色
  • render函数动态修改样式
  • google推广中SEO与SEM优劣势大对比
  • 回溯——4.分割回文串
  • yolo8 目标检测、鉴黄
  • nginx访问控制、用户认证、https、负载均衡
  • PMP核心知识点—之项目运行环境
  • Java基础 2. Java基础语法
  • EasyExcel导出动态合并行单元格
  • 原生冻结进程分析(U)
  • 数据仓库系列19:数据血缘分析在数据仓库中有什么应用?
  • 基础服务安装部署教程
  • UE 【材质编辑】自定义ShadingMode
  • [Labview]图片叠加下的表格视图拖拽功能:挖坑粗糙版
  • IP SSL证书——为IP升级加密
  • 2018天猫双11|这就是阿里云!不止有新技术,更有温暖的社会力量
  • css选择器
  • ESLint简单操作
  • Fastjson的基本使用方法大全
  • iOS小技巧之UIImagePickerController实现头像选择
  • Js实现点击查看全文(类似今日头条、知乎日报效果)
  • JS题目及答案整理
  • js作用域和this的理解
  • MySQL QA
  • MySQL常见的两种存储引擎:MyISAM与InnoDB的爱恨情仇
  • npx命令介绍
  • rabbitmq延迟消息示例
  • Vue 2.3、2.4 知识点小结
  • 产品三维模型在线预览
  • 关于Flux,Vuex,Redux的思考
  • 基于Android乐音识别(2)
  • 基于阿里云移动推送的移动应用推送模式最佳实践
  • 设计模式 开闭原则
  • 使用Gradle第一次构建Java程序
  • 格斗健身潮牌24KiCK获近千万Pre-A轮融资,用户留存高达9个月 ...
  • ​​​​​​​​​​​​​​汽车网络信息安全分析方法论
  • (42)STM32——LCD显示屏实验笔记
  • (done) 两个矩阵 “相似” 是什么意思?
  • (Java数据结构)ArrayList
  • (ZT)出版业改革:该死的死,该生的生
  • (ZT)薛涌:谈贫说富
  • (利用IDEA+Maven)定制属于自己的jar包
  • (论文阅读23/100)Hierarchical Convolutional Features for Visual Tracking
  • (四)汇编语言——简单程序
  • (学习日记)2024.01.09
  • (一)认识微服务
  • (原创)可支持最大高度的NestedScrollView
  • (转)winform之ListView
  • (转)关于多人操作数据的处理策略
  • (转)清华学霸演讲稿:永远不要说你已经尽力了
  • (自用)网络编程
  • .java 9 找不到符号_java找不到符号
  • .NET 8 跨平台高性能边缘采集网关
  • .NET Core 发展历程和版本迭代
  • .Net Core 中间件验签