Archive

Archive for August, 2012

Import XML data to MySQL tables

01/08/2012 1 comment

According to mysql documentation there is possibility to load data to mysql table from xml files. Hoverer after trying to execute below command:

napi@debian:/home/napi$ mysql -u root -p
mysql> use test;
Database changed
mysql> LOAD XML LOCAL INFILE '/var/www/SIMC.xml' INTO TABLE simc;
ERROR 1148 (42000): The used command is not allowed with this MySQL version

as a output I get this weird error. To fix that just add one parameter: ‘–local-infile’ to mysql command:

napi@debian:/home/napi$ mysql -u root -p --local-infile
mysql> use test;
Database changed
mysql>  LOAD XML LOCAL INFILE '/var/www/SIMC.xml' INTO TABLE simc;
Query OK, 4115 rows affected, 1580 warnings (0.85 sec)
Records: 4115  Deleted: 0  Skipped: 0  Warnings: 1580
Advertisements
Categories: PHP + MySQL