bin/sqoop list-databases --connect jdbc:mysql://localhost:3306/ --username root --password hadoop
##导入mysql表数据到HDFS
bin/sqoop import \
--connect jdbc:mysql://node-1:3306/userdb \
--username root \
--password hadoop \
--target-dir /sqoopresult212 \
--table emp --m 1
bin/sqoop import \
--connect jdbc:mysql://node-1:3306/userdb \
--username root \
--password hadoop \
--target-dir /sqoopresult213 \
--fields-terminated-by '\t' \
--table emp --m 1
bin/sqoop import \
--connect jdbc:mysql://node-1:3306/userdb \
--username root \
--password hadoop \
--target-dir /sqoopresult214 \
--fields-terminated-by '\t' \
--split-by id \
--table emp --m 2
hdfs dfs -cat /sqoopresult/part-m-00000
导入mysql表数据到HIVE
将关系型数据的表结构复制到hive中
bin/sqoop create-hive-table \
--connect jdbc:mysql://node-1:3306/userdb \
--table emp_add \
--username root \
--password hadoop \
--hive-table test.emp_add_sp
其中 --table emp_add为mysql中的数据库sqoopdb中的表
–hive-table emp_add_sp 为hive中新建的表名称
从关系数据库导入文件到hive中
bin/sqoop import \
--connect jdbc:mysql://node-1:3306/userdb \
--username root \
--password hadoop \
--table emp_add \
--hive-table test.emp_add_sp \
--hive-import \
--m