Solve sqoop to import data into mysql garbled

mysql character set modification:
(system before 5.5)#vim /etc/mysql/my.cnf .
Add default-character-set=utf8 under [client]
Notice: Note: If you can't start the error report after modification, try changing default-character-set=utf8 to character_set_server=utf8, just add the .client under mysqld without adding (systems after

5.5) are modified as follows:
#vim /etc/mysql/my.cnf .
[client]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
2. Command /etc/init.d/mysqld restart to restart MySQL.
// 3.set names utf8;

Create a database:
create database sqoop default character set 'utf8' COLLATE 'utf8_general_ci';
Create a table:
CREATE TABLE test23(time varchar(30), userid varchar(255), query text, pagerank varchar(255), clickrank varchar(255), site text)ENGINE=InnoDB DEFAULT CHARSET=utf8;

sqoop导入mysql命令:

bin/sqoop export --connect "jdbc:mysql://localhost:3306/sqoop?useUnicode=true&characterEncoding=utf-8"  --username root --password git1024 --table test23 --export-dir /user/hive/warehouse/sogouqueryfish/day\=2014-01-01/test3.txt --input-fields-terminated-by '\t' --input-null-string '' --input-null-non-string ''

test success! happy!
----------------


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326777670&siteId=291194637