Neo4j1.5.8 installation tutorial under Windows10

foreword

Neo4j is a high-performance, NOSQL graph database that stores structured data on the network rather than in tables. A disk-based, Java persistence engine with complete transactional features will not be compared with commonly used relational databases here. Due to limited space, it is also the first time I use it here, so the following is a nanny-level installation tutorial.

installation steps

1. Open Neo4j official website, find "Developers" and select "Download Center".

2. There are enterprise version, community version and desktop version available for download, here I choose "Neo4j Desktop", if it is deployment, you can choose community or enterprise.

3. Select the Windows exe to enter, and it is required to fill in the information before downloading. Do not close the web page after the download box pops up, as the activation code inside will be needed later.

4. Since Neo4j is disk storage, set the storage location of the data first after opening.

5. Then go back to the official website after downloading, copy the activation code, and paste it into the "Software key" of the tool.

Instructions

1. Testing Services

First check whether the service is enabled, open the default database, and you can see the connection address and ports of various protocols.

2. Start connection

Open the browser, enter 127.0.0.1:7474, and enter neo4j for both the account and password. The login fails and an error is reported: Neo.ClientError.Security.Unauthorized: The client is unauthorized due to authentication failure

3. Change password

Find the neo4j service desktop, find the default database, find "Reset DBMS Password", and then re-enter the user "neo4j" and the new password to log in.

4. Client panel

After successful login, you can see the data nodes and content in neo4j's default database "Movide DBMS".

Practical

1. Create a project

Create a new project in Project, then add a "Local DBMS", then set the name and password, and click Start after creation.

2. Web client login

According to the address and port provided after creation, visit in the browser, enter the user name and set password, and you will enter the corresponding picture.

3. Dependency installation

Add the "py2neo" package to the python project, and then test the connection, node creation and relationship edge creation.

pip install py2neo -i https://pypi.tuna.tsinghua.edu.cn/simple

4. Test creation of nodes and relationship edges

import os
import json
from py2neo import Graph,Node

class ThingGraph:
    def __init__(self):
        self.neo4j = Graph(
            host="127.0.0.1",  # neo4j 搭载服务器的ip地址,ifconfig可获取到
            http_port=7474,  # neo4j 服务器监听的端口号
            user="neo4j",  # 数据库user name,如果没有更改过,应该是neo4j
            password="beiqiaosu123456")

    def create_nodes(self):
        class_name = ["手机", "笔记本", "平板", "游戏机", "台式机"]
        brand = ["苹果", "华为", "小米", "Vivo", "Oppo"]
        goods = ["苹果 iPhone 4S", "华为 nova 3e", "华为 T8620", "联想ThinkPad W701"]
        return self.create_node('Goods', goods)

if __name__ == "__main__":
    things_graph = ThingGraph()
    things_graph.create_nodes()

If the following settings are not supported: {'http_port': 7474} appears when running the code, it is because the installed py2neo version is too high, you can lower the version and run it again.

pip install py2neo==4.3.0 -i https://pypi.douban.com/simple

After lowering the py2neo version, I found that the error was still reported after running. AttributeError: 'NoneType' object has no attribute 'pool'. The main reason is that I can't connect to Neo4j. After checking, it was found that the previous wording was wrong, and the latest version of neo4j was installed. The same py2neo also needs to be installed. newer.

# 创建一个名为 'Person' 的节点
person = Node('Goods', name='T8620')
# 创建一个 Graph 对象,并指定数据库连接信息
graph = Graph('bolt://localhost:7687', auth=('neo4j', 'beiqiaosu123456'))
# 将节点添加到 Graph 中
graph.create(person)

After I deleted the py2neo package, I installed py2neo 2021.2.3 without specifying the version. After running the code and checking it in the browser, the node "Goods" has been created, and the subsequent data synchronization and associated side operations will have to wait until the knowledge quiz is completed After the system is summarized and shared.

Guess you like

Origin blog.csdn.net/qq_35704550/article/details/131854356