安装win版本的neo4j(2023最新版本)

写在最前面

谁能想到最后还是学知识图谱了呢,真是啥都要学啊,躲不过~

参考:https://blog.csdn.net/qq_38335648/article/details/115027676

安装 win版本的neo4j

Neo4j是一个高性能的NOSQL图形数据库,它将结构化数据存储在网络上而不是表中。由于知识图谱中存在大量的关系型信息(实体—关系—实体), 使用结构化数据库进行存储将产生大量的冗余存储信息, 因此将图数据库作为知识图谱的存储容器成为流行的选择。当前较为常用的图数据库主要有 Neo4j 等。

1. 安装JDK

下载neo4j之前,首先要安装JDK。
相信大家已经安装了hhh,没安装可参考:https://blog.csdn.net/qq_38335648/article/details/115027676

2.下载

下载地址:https://neo4j.com/download-center/
在这里插入图片描述
下载好之后,直接解压到合适的路径就可以了,无需安装。

配置环境变量(也可选择直接点击快捷方式,就可以不用配环境了)

接下来要配置环境变量了,与刚才JAVA环境变量的配置方法极为相似,因此在这里只进行简单描述。

在系统变量区域,新建环境变量,命名为NEO4J_HOME,变量值设置为刚才neo4j的安装路径。
编辑系统变量区的Path,点击新建,然后输入 %NEO4J_HOME%\bin,最后,点击确定进行保存就可以了。

3. 启动neo4j

以管理员身份运行cmd。
在命令行处输入neo4j.bat console

如出现此界面,则证明neo4j启动成功。
在浏览器中输入界面中给出的网址http://localhost:7474/,则会显示如下界面。
在这里插入图片描述

扫描二维码关注公众号,回复: 16019720 查看本文章

默认的用户名和密码均为neo4j。
不过建议新建一个project,原来的那个project遇到各种各样的报错。。。
在这里插入图片描述
新建要求密码至少8个字符

登录之后就可以进行下一步的学习使用啦
至此,neo4j安装完毕 O(∩_∩)O

在这里插入图片描述

测试代码

代码运行前,记得把相应的project start
在这里插入图片描述

from py2neo import Graph, Node, Relationship

# Graph()中第一个为local host链接,name为指定数据库名称,auth为认证,包含 username(neo4j) 和 password(12345678),注意改成自己的
graph = Graph('http://localhost:7474', auth = ('neo4j', '12345678'), name='neo4j')

a = Node("hero", name="Clint")  # Node(label, name)
b = Node("hero", name="Natasha")
ab = Relationship(a, "friend", b)
graph.create(ab)  # 创建节点和关系

没有报错,且显示下图就成功啦
在这里插入图片描述

遇到的问题及解决(每次环境都太离谱了,各种问题)

参考:https://blog.csdn.net/JD_Wang0/article/details/104408190

连接后更新密码

测试出现:访问Neo4j验证失败(The client is unauthorized due to authentication failure.)

参考:https://blog.csdn.net/weixin_39198406/article/details/85068102

解决方法:修改neo4j.conf配置文件,取消验证机制,修改如下:
dbms.security.auth_enabled=false

This DBMS can’t be found at the moment, it might be located in a location that is currently not connected to this device.

还有 ServiceUnavailable: WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver. Please use your browsers development console to determine the root cause of the fail

建议重装,官网都没有回答
但注意:卸载前删除所有缓存文件
一般缓存文件在用户目录下
在这里插入图片描述

问题:neo4j desktop 重装后,数据库出现感叹号

在这里插入图片描述
解决:新建project,以重设密码
或参考https://blog.csdn.net/qq_34045989/article/details/115458261

测试代码报错

py2neo.errors.ProtocolError: Cannot decode response content as JSON

解决方法:
之前的代码:

g = Graph("http://localhost:7474//browser")

连接时指定数据库名称,使用下面的的连接方式

g = Graph("http://localhost:7474//browser", name='neo4j')

参考:https://blog.csdn.net/qq_23044461/article/details/127879715

猜你喜欢

转载自blog.csdn.net/wtyuong/article/details/131838658