I have a file containing ipv6 addresses represented as very large integers. When I import it into mysql the data is wrong. What do I need to do in order to get the load data to properly import the data into a binary(16) column?
Schema:
CREATE TABLE `ipv6_test` (
`ip` binary(16) NOT NULL,
`name` varchar(128) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
CSV file to import, ipv6_test.csv:
"58569107296622255421594597096899477505","test"
MySQL import command:
mysql> load data local infile 'ipv6_test.csv' into table ipv6_test fields terminated by ',' enclosed by '"' lines terminated by '\n';
Query:
select ip, INET6_NTOA(ip), name from ipv6_test;
Incorrect Results:
+------------------+-----------------------------------------+------+
| ip | INET6_NTOA(ip) | name |
+------------------+-----------------------------------------+------+
| 5856910729662225 | 3538:3536:3931:3037:3239:3636:3232:3235 | test |
+------------------+-----------------------------------------+------+
Expected Results:
+------------------+-----------------------------------------+------+
| ip | INET6_NTOA(ip) | name |
+------------------+-----------------------------------------+------+
| ? binary data ? | 2C0F:FFF0:0000:0000:0000:0000:0000:0001 | test |
+------------------+-----------------------------------------+------+