数据库
首页 > 数据库> > 使用Neo4j的apoc插件,实现数据从MySQL抽取到Neo4j

使用Neo4j的apoc插件,实现数据从MySQL抽取到Neo4j

作者:互联网

1、准备

下载地址:https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/3.4.0.7

注意:apoc版本必须和你Neo4j的版本差不多,例如你的Neo4j版本是3.5.x,apoc的版本也要是3.5.x左右

image

将这两个插件放在neo4j安装目录下的plugins文件夹下面

2、配置Neo4j可以使用apoc.*

在Neo4j配置文件XXXX\neo4j-community-3.5.5\conf\neo4j.conf中搜索dbms.security.procedures.unrestricted,在后面加上apoc.*,中间用英文逗号分隔,如下:

dbms.security.procedures.unrestricted=my.extensions.example,my.procedures.*,apoc.*

较完整的 neo4j.conf 配置:

点击查看代码
dbms.directories.import=import
dbms.security.auth_enabled=true
# Bolt协议端口
dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL
dbms.connector.bolt.listen_address=:7687
# HTTP Connector. There can be zero or one HTTP connectors. 
# HTTP协议端口
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:7474
# HTTPS Connector. There can be zero or one HTTPS connectors.
dbms.connector.https.enabled=true
dbms.connector.https.listen_address=:7473
dbms.tx_log.rotation.retention_policy=1 days
dbms.security.procedures.unrestricted=my.extensions.example,my.procedures.*,apoc.*,rxx.*
dbms.jvm.additional=-XX:+UseG1GC
dbms.jvm.additional=-XX:-OmitStackTraceInFastThrow
dbms.jvm.additional=-XX:+AlwaysPreTouch
dbms.jvm.additional=-XX:+UnlockExperimentalVMOptions
dbms.jvm.additional=-XX:+TrustFinalNonStaticFields
dbms.jvm.additional=-XX:+DisableExplicitGC
dbms.jvm.additional=-Djdk.tls.ephemeralDHKeySize=2048
dbms.jvm.additional=-Djdk.tls.rejectClientInitiatedRenegotiation=true
dbms.windows_service_name=neo4j
dbms.jvm.additional=-Dunsupported.dbms.udc.source=zip

3、使用

在Neo4j浏览器输入call apoc.load.driver('com.mysql.jdbc.Driver')加载驱动:

image

然后就可以使用Neo4j连接MySQL数据库查询数据了
image

示例:

CALL apoc.periodic.iterate(
	'CALL apoc.load.jdbc("jdbc:mysql://localhost:3306/neo4jtest?user=root&password=123456","select * from student") YIELD row ',
	'CREATE (s:Student) SET s =row',
	{ batchSize:10000, parallel:true}
)

标签:插件,additional,dbms,connector,jvm,neo4j,Neo4j,apoc
来源: https://www.cnblogs.com/rxx1005/p/15786471.html