d2rq-0.8.1工具构建RDF模型

构建知识图谱时,需要使用d2rq-0.8.1工具构建RDF模型,参照官文http://d2rq.org/getting-started操作时,执行如下命令,报错了

generate-mapping -o mapping.ttl -u root -p a12345 jdbc:mysql://localhost/testdb

报错内容,
MySQL 8.0 - Client does not support authentication protocol requested by server; consider upgrading MySQL client


解决方案,

Step 1:
打开MySQL Workbench,在SQL查询页面(File->New Query Tab),执行以下SQL,这里的a12345是我的旧root密码。

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'a12345';
flush privileges;

这时候我再执行以下命令时,又报错了

generate-mapping -o mapping.ttl -u root -p a12345 jdbc:mysql://localhost/testdb

错误如下,
Database connection to jdbc:mysql://localhost/kg_demo_movie failed (user: root): Unknown initial character set index ‘255’ received from server. Initial client character set can be forced via the ‘characterEncoding’ property. (E54)

Step 2:
去官网下载最新的驱动mysql-connector-java-5.1.47-bin.jar替换原来的旧驱动mysql-connector-java-5.1.18-bin.jar
注:一般位于\d2rq-0.8.1\lib\db-drivers路径下。

现在一切都正常了……

我在推测,是不是直接替换驱动jar就可以了呢?而不需要执行Step 1。


©qingdujun
2018-9-5 于 北京 海淀

References:
[1] https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server
[2] https://stackoverflow.com/questions/50855622/unknown-initial-character-set-index-255-received-from-server

附录:

[1] D2RQ官文说如果是MySQL数据库可以省略-d com.mysql.jdbc.Driver。另外,最后在url后面指定编码格式?useUnicode=true&characterEncoding=utf8,否则可能会有意想不到的惊喜!完整命令如下:
generate-mapping -o mapping.ttl -d com.mysql.jdbc.Driver -u root -p a12345 jdbc:mysql://localhost/testdb?useUnicode=true&characterEncoding=utf8

[2] 一个警告。Wed Sep 05 14:28:19 CST 2018 WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

猜你喜欢

转载自blog.csdn.net/u012339743/article/details/82423809