• Ubuntu 20.04 上安装和配置 neo4j



    1. 进入要安装neo4j的ubuntu环境。

    2. 添加Debian资源库。

    java 1.8.xx版本对应neo4j 3.xx版本(jdk 11版本对应neo4j 4.xx版本):

    (1)wget -O - https://debian.neo4j.com/neotechnology.gpg.key | sudo apt-key add -
    (2)echo 'deb https://debian.neo4j.com stable 3.5' | sudo tee /etc/apt/sources.list.d/neo4j.list(或者:echo 'deb https://debian.neo4j.com stable 4.4' | sudo tee /etc/apt/sources.list.d/neo4j.list)
    (3)sudo apt-get update
    3. 安装社区版neo4j:

    sudo apt-get install neo4j
    4. 此时可查看其运行状态:

    sudo systemctl status neo4j.service
    5. 设置为在系统重新启动时启动:

    (1)sudo systemctl enable neo4j.service

    (2)sudo systemctl start neo4j.service

    *(3)sudo systemctl status neo4j.service

    6. 连接和配置neo4j。

    (1)测试连接到数据库:

    cypher-shell。
    默认neo4j 用户名和 neo4j 密码。

    :exit。

    7. 修改密码。

    ~$ cypher-shell
    username: neo4j
    password: neo4j

    neo4j> CALL dbms.changePassword('yournewpassword');
    0 rows available after 24 ms, consumed after another 0 ms
    neo4j> 

    8. 使用neo4j。

    $ cypher-shell
    username: neo4j
    password: ********
    Connected to Neo4j 3.5.35 at bolt://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> 

    密码输入错误会提示:

    username: neo4j
    password: *****
    The client is unauthorized due to authentication failure.

    9.关闭和启动。

    sudo neo4j stop

    sudo neo4j start

    10. 新建和切换数据库。

    社区版不支持用create database yourdbname创建。

    社区版只可同时打开一个数据库,但可以存在多个数据库。

    在/etc/neo4j/neo4j.conf中做如下修改:

    #dbms.default_database=neo4j

    dbms.default_database=neo4yours

    对于社区版,此修改可实现数据库的切换,每次切换均需修改,use database命令不可用。

    关闭neo4j并重启,neo4j会自动创建neo4yours:

    cd ../bin

    ./neo4j restart

    11. Web Browser。

    服务处于开启状态:
    http://localhost:7474

    Start querying

    12. Desktop。

    服务处于开启状态:

    bolt://localhost:7687

    Connect -> Open -> Start querying

    13. 试用。

    match(n) return n

    14. 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")


    References:

    https://blog.csdn.net/BigData_Mining/article/details/122308250

    如何在Ubuntu20.04上安装和配置Neo4j - 菜鸟教程
    【精选】图数据库-Neo4j(六):创建/切换数据库(不删旧)【社区版只能同时一个数据库活动,修改neo4j.conf默认/活动数据库为此时需要用到的数据库名】【Neo4.x企业版可以同时多个活动数据库】_neo4j创建数据库-CSDN博客

  • 相关阅读:
    在哪里可以制作一本精美的翻页产品册呢?
    【模型剪枝】| yolov5 模型分析及剪枝
    厉害了,腾讯内部都用的Spring+MyBatis源码手册,实战理论两不误
    黄金投资面对K线图有哪些好用的交易策略?
    利用IoDriverObjectType控制内核驱动加载
    老卫带你学---leetcode刷题(88. 合并两个有序数组)
    【光学】基于matlab模拟单缝夫琅禾费衍射
    重磅!华秋电子再次入选“中国产业数字化百强榜”
    计算模型参数量
    CAN 通信-底层
  • 原文地址:https://blog.csdn.net/u014677900/article/details/133925578