Import MySQL into Hive
direct import
bin/sqoop import \
--connect jdbc:mysql://127.0.0.1:3306/yqzb \
--username root \
--password root \
--table jxjkm_jcx \
--fields-terminated-by '\001' \
--delete-target-dir \
--num-mappers 1 \
--hive-import \
--hive-database test \
--hive-table jxjkm_jcx
indirect import
bin/sqoop import \
--connect jdbc:mysql://127.0.0.1:3306/test \
--username root \
--password root123 \
--query 'select id, username,password from user_info where $CONDITIONS' \
--target-dir /data/test/user_info \ # HDFS的地址
--delete-target-dir \ # 如果存在则删除
--num-mappers 1 \
--split-by id \
--compress \ # 启动压缩
--compression-codec org.apache.hadoop.io.compress.SnappyCodec \
--hive-drop-import-delims \ # 去除\n, \r, and \01,但是实际运用有问题
--direct \
--fields-terminated-by '\001' \
--lines-terminated-by '\n'
Load operation
load data inpath '/data/test/user_info' into table user_test.user_info ;