Neo4j---(1)导入导出dump文件

本文详细介绍了如何在Windows上安装Neo4j服务,启动和关闭数据库,以及如何导入和导出dump文件。在导入过程中,提到了解决版本升级问题的方法,同时强调了在导入和导出前需确保数据库的状态正确。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、基本语句

1.进入Neo4j的bin文件夹:D:\>cd D:\neo4j\neo4j-community-4.4.18\bin

2.建立服务:neo4j install-service

 3.开启Neo4j:neo4j start /console

  • start:  (1)启动很快 (2)终端即使关闭后台也在运行 (3)要用neo4j stop才能关闭
  • console:(1)启动很慢 (2)终端关闭则neo4j也关闭

4.关闭Neo4j:neo4j stop

5.Neo4j状态查询:neo4j status

C:\Windows\system32>D:

D:\>cd D:\neo4j\neo4j-community-4.4.18\bin

D:\neo4j\neo4j-community-4.4.18\bin>neo4j install-service
Neo4j service installed.

D:\neo4j\neo4j-community-4.4.18\bin>neo4j start
Directories in use:
home:         D:\neo4j\neo4j-community-4.4.18
config:       D:\neo4j\neo4j-community-4.4.18\conf
logs:         D:\neo4j\neo4j-community-4.4.18\logs
plugins:      D:\neo4j\neo4j-community-4.4.18\plugins
import:       D:\neo4j\neo4j-community-4.4.18\import
data:         D:\neo4j\neo4j-community-4.4.18\data
certificates: D:\neo4j\neo4j-community-4.4.18\certificates
licenses:     D:\neo4j\neo4j-community-4.4.18\licenses
run:          D:\neo4j\neo4j-community-4.4.18\run
Starting Neo4j.
Started neo4j. It is available at http://localhost:7474
There may be a short delay until the server is ready.

D:\neo4j\neo4j-community-4.4.18\bin>neo4j status
Neo4j is running

二、导入dump文件

  • neo4j必须在关闭状态
  • 创建新的数据库来导入

1.关闭neo4j并查看状态:neo4j stop /// neo4j status

  • 若stop不能停止,则用 kill -s 9 强制关闭进程
D:\neo4j\neo4j-community-4.4.18\bin>neo4j stop
Stopping Neo4j........ stopped.

D:\neo4j\neo4j-community-4.4.18\bin>neo4j status
Neo4j is not running.

2.创建新数据库:要在配置文件中建立

  • 先进入安装目录找到配置文件:D:\neo4j\neo4j-community-4.4.18\conf\neo4j.conf
  • 定位行:#dbms.default_database=neo4j
  • 在下面直接添加要创建的数据库:dbms.active_database=shield.db
  • 注意数据库名字不能用下划线
  • 新建数据库在data文件夹下的database文件夹中
# The name of the default database
#dbms.default_database=neo4j
#dbms.default_database=my-test-database
dbms.active_database=shield.db

3.导入dump文件命令

  • neo4j-admin load --from=<需要导入文件的地址> --database=<导入的数据库> --force
  • --from:需要导入的数据文件路径
  • --database:新的数据库名称(xx.db
  • --force :强制覆盖源数据库(此时是新建立的数据库 无影响)
D:\neo4j\neo4j-community-4.4.18\bin>
neo4j-admin load --from=D:\neo4j\neo4j-community-4.4.18\import\import-file.db.dump --database=shield.db --force

4.导入时版本升级报错

  • 解决方法:在配置为文件中将 dbms.allow_upgrade=true 打开
D:\neo4j\neo4j-community-4.4.18\bin>neo4j-admin load --from=D:\neo4j\neo4j-community-4.4.18\import\shieldgraph.db.dump --database=shield.db --force
Selecting JVM - Version:11.0.14+8-LTS-263, Name:Java HotSpot(TM) 64-Bit Server VM, Vendor:Oracle Corporation
Done: 34 files, 281.5KiB processed.
The loaded database is not on the latest format (current:v0.A.9, latest:SF4.3.0). Set dbms.allow_upgrade=true to enable migration.
# Enable this to be able to upgrade a store from an older version.
dbms.allow_upgrade=true

5.导入后重启neo4j:neo4j start

D:\neo4j\neo4j-community-4.4.18\bin>neo4j start
Directories in use:
home:         D:\neo4j\neo4j-community-4.4.18
config:       D:\neo4j\neo4j-community-4.4.18\conf
logs:         D:\neo4j\neo4j-community-4.4.18\logs
plugins:      D:\neo4j\neo4j-community-4.4.18\plugins
import:       D:\neo4j\neo4j-community-4.4.18\import
data:         D:\neo4j\neo4j-community-4.4.18\data
certificates: D:\neo4j\neo4j-community-4.4.18\certificates
licenses:     D:\neo4j\neo4j-community-4.4.18\licenses
run:          D:\neo4j\neo4j-community-4.4.18\run
Starting Neo4j.
Started neo4j. It is available at http://localhost:7474
There may be a short delay until the server is ready.

6.打开 http://localhost:7474即可看到新导入的数据库及文件

 三、导出dump文件

1.要先关闭数据库

2.导出dump文件命令

  • neo4j-admin dump --database=<导出的数据库> --to=<需要导出文件的地址> 
  • --database:数据库名称(xx.db
  • --to:需要导入的数据文件路径与保存文件名称

D:\neo4j\neo4j-community-4.4.18\bin>neo4j-admin dump --database=ceshi.db --to=D:\neo4j\neo4j-community-4.4.18\dump\ceshi.db.dump

Selecting JVM - Version:11.0.14+8-LTS-263, Name:Java HotSpot(TM) 64-Bit Server VM, Vendor:Oracle Corporation
Done: 36 files, 968.5KiB processed

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值