mysql - 我们可以使用 sqoop 导出特殊字符吗?
问题描述
我正在尝试使用 sqoop 导出将其中一张表从配置单元导出到 MySQL。配置单元表数据包含特殊字符。
我的蜂巢“special_char”表数据:
1 じゃあまた
2 どうぞ
我的 Sqoop 命令:
sqoop export --verbose --connect jdbc:mysql://xx.xx.xx.xxx/Sampledb --username abc --password xyz --table special_char --direct --driver com.mysql.jdbc.Driver --export-dir /apps/hive/warehouse/sampledb.db/special_char --fields-terminated-by ' '
使用上述 sqoop 导出命令后,数据以问号(???)的形式存储,而不是带有特殊字符的实际消息。
MySql“special_char”表:
id message
1 ?????
2 ???
谁能帮我存储特殊字符而不是问号(???)。
解决方案
在 JDBC URL 中指定正确的编码和字符集,如下所示:
jdbc:mysql://xx.xx.xx.xxx/Sampledb?useUnicode=true&characterEncoding=UTF-8
sqoop export --verbose --connect jdbc:mysql://xx.xx.xx.xxx/Sampledb?useUnicode=true&characterEncoding=UTF-8 --username abc --password xyz --table special_char --direct --driver com.mysql.jdbc.Driver --export-dir /apps/hive/warehouse/sampledb.db/special_char --fields-terminated-by ' '
请验证日文字符的字符集编码并使用正确的字符集。
推荐阅读
- ansible - 使用 Ansible 指定涉及 2 个网络接口和流量方向的 ufw 规则
- gpu - 将 batch_size 加倍会比在两个模型上运行 tensorrt 更快吗?
- c++ - 如何扩展 boost geometry union_ 策略以使用附加数据处理自己的多边形类型?
- java - 如何将文本字段转换为链接
- javascript - API在Typescript中接收未知的正文或参数,如何检查类型
- redis - 如何停止在 development.log 上无休止地重复 redis 和 sidekiq 日志
- ios - iOS 对象检测横向缩放检测
- reactjs - 授权应用程序调用 API Azure AD 时出现 CORS 错误?
- javascript - 您能否制作一种根据字符串输入更改不同变量的方法
- powershell - 如何从 Ansible 管理 var value off Powershell 中的目录