1、vim /etc/my.cnf添加
===========================
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
[client]
default-character-set = utf8
===========================
重启mysqld
2、建表指定 utf8mb4_unicode_ci,否则执行插入任务会报错
yarn logs -applicationId application_1653098626231_0006 查看报错:
org.apache.hadoop.mapred.YarnChild: Exception running child : java.io.IOException: java.sql.SQLException: Incorrect string value: '\xE9\x83\x91\xE6\x98\x8E' for column 'name' at row 1
CREATE TABLE `s4` (
`id` int(11) NOT NULL DEFAULT '0',
`name` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;