sqoop从mysql导入hive

1. mysql表user对象信息

 

CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(128) DEFAULT NULL,
  `password` varchar(128) DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

 2. 利用sqoop创建对应的hive表

 

sqoop create-hive-table --connect jdbc:mysql://localhost:3306/test --table user  --username root --password root --hive-table user

 3.sqoop从mysql导入hive脚本文件mysql2hive.opt

import 
--connect
jdbc:mysql://192.168.102.103:3306/test
--username 
root
--password
root
-m
1
--null-string
''
--table 
user
--columns 
"id,username,password,age"
--where
1=1
--hive-import
--hive-overwrite
--hive-drop-import-delims
--hive-table
user

 4. 执行sqoop脚本

sqoop --options-file mysql2hive.opt

 

 

你可能感兴趣的:(sqoop从mysql导入hive)