I cannot reproduce it :-?
My dumps include this as script header:
;
... and this as script footer:
;
That seems to address both potential problems (foreign key creation and data insertion), at least in my computer:
;
;
;
;
;
CREATE TABLE IF NOT EXISTS `a` (
`a_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`a_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`b_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`a_id`),
KEY `FK_a_b` (`b_id`),
CONSTRAINT `FK_a_b` FOREIGN KEY (`b_id`) REFERENCES `b` (`b_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
;
INSERT INTO `a` (`a_id`, `a_name`, `b_id`) VALUES
(1, 'Parent row', 1);
;
CREATE TABLE IF NOT EXISTS `b` (
`b_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`b_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`b_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
;
INSERT INTO `b` (`b_id`, `b_name`) VALUES
(1, 'Child row');
;
;
;
;