常用命令:
查看hive中表的結構: desc table_name;
查看hive中表的詳細結構:desc formatted table_name;

我們想要將hive表中的資料匯出到MySQL當中,MySQL中必須要有一個表來接收,并且該表的結構要和hive當中的表結構一致,不然會報錯,
踩坑:hive當中的 string 欄位對應 MySQL當中的 varchar 型別
直接上代碼:
sqoop export --connect "jdbc:mysql://192.168.56.101:3306/dbFood?useUnicode=true&characterEncoding=utf-8" --username root --password root --table test05 --fields-terminated-by '\001' --lines-terminated-by '\t' --export-dir /hadoop/hive312/data/warehouse/test03
復制粘貼的時候建議先弄到記事本當中把代碼合并成一行 --export-dir 后面有一個空格
!!!重點 : 如果報錯就把 '\001' 替換為 ','

ip 用戶名和密碼等引數就不說了,
引數1:MySQL當中要接收資料的表名
引數2:要匯出表的所在路徑 可以通過 desc formatted table_name; 查看
引數3:分隔符

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/352148.html
標籤:其他
