Home > PHP + MySQL > Import XML data to MySQL tables

Import XML data to MySQL tables

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
Categories: PHP + MySQL
  1. 18/09/2013 at 13:23

    Thanks a lot … it worked for me …🙂

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: