hive导出到mysql
上一节
下一节
1、创建mysql空表
mysql -uroot -pzjw
use userdb;
DROP TABLE IF EXISTS `emp_export`;
CREATE TABLE `emp_export` (
`id` int(11) NOT NULL,
`name` varchar(100) DEFAULT NULL,
`deg` varchar(100) DEFAULT NULL,
`salary` int(11) DEFAULT NULL,
`dept` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
);
2、执行导出
先执行导入
sqoop import --connect jdbc:mysql://192.168.1.7:3306/userdb --username root --password zjw --table emp --hive-table itcast.emp --create-hive-table --hive-import --num-mappers 1
在执行导出
sqoop export --connect jdbc:mysql://192.168.1.7:3306/userdb -username root --password zjw --table emp_export --export-dir /hive/warehouse/itcast.db/emp

