Raw CSV data is made available by Common Data Hub here:
http://www.commondatahub.com/live/geography/state_province_region/iso_3166_2_state_codes
http://www.commondatahub.com/live/geography/country/iso_3166_country_codes
The table cdh_state_codes
(see cdh-schema.sql
below) is designed to hold the raw data, which should import readily using most common database tools, or directly into MySQL via LOAD DATA, e.g.:
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE TABLE iso3166
.cdh_state_codes
;