0

I need to load 400+ xml files in a single mysql table using phpmyadmin. These files are local. I know I can import one single file per time (clicking on "import"), but I suppose there's a sql code to load all files automatically.

I tried "LOAD XML LOCAL INFILE 'filename.xml' INTO TABLE tablename;" but it returns this error: "#2068 - LOAD DATA LOCAL INFILE is forbidden, check related settings like mysqli.allow_local_infile|mysqli.local_infile_directory or PDO::MYSQL_ATTR_LOCAL_INFILE|PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY".

I tried to see if here "Load data local infile" command not allowed there was the solution but they say I should modify the file "my.cnf". I don't have this file, so I'm stacked.

Thank you!

Maria
  • 1
  • 2
  • Have you researched similar questions, such as [How to import multiple xml files into mysql table](https://stackoverflow.com/questions/54982660/how-to-import-multiple-xml-files-into-mysql-table) or [How to load Multiple XML files to MySQL using java](https://stackoverflow.com/q/55135134/12567365), and others? Even if they do not provide usable solutions for your situation (e.g. if you do not want to use Java), showing us your research may help you to get a better answer, or help you to ask a more focused question. – andrewJames Aug 09 '22 at 15:40
  • Yes, but I didn't understand how to do it. I can write php (I would prefer to not use Java). – Maria Aug 09 '22 at 15:48
  • I tried to do what is shown in this page https://dev.mysql.com/doc/refman/8.0/en/load-xml.html but the command "LOAD XML" returns errors. – Maria Aug 09 '22 at 15:53
  • OK - thank you. So, maybe this: [import xml file into mysql database using php](https://stackoverflow.com/questions/25446653/import-xml-file-into-mysql-database-using-php), or maybe this: [Import XML with attributes into mysql](https://stackoverflow.com/q/14234563/12567365)? And various similar PHP questions on Stack Overflow? Do any of those help? If not, can you [edit] your question to show where you are getting stuck, what code you are using, some sample data, and what error(s) you get? – andrewJames Aug 09 '22 at 15:54
  • I read all the links and I think the easiest solution is to use "LOAD XML LOCAL INFILE 'filename.xml' INTO TABLE tablename;". I tried but this is the result: "#2068 - LOAD DATA LOCAL INFILE is forbidden, check related settings like mysqli.allow_local_infile|mysqli.local_infile_directory or PDO::MYSQL_ATTR_LOCAL_INFILE|PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY" – Maria Aug 09 '22 at 16:05
  • You can [edit] your question, to refine it. Show where you are getting stuck, what code you are using, some sample data, and what error(s) you get. Did you research that error you mentioned in your comment? For example by looking at [LOAD DATA LOCAL INFILE forbidden in... PHP](https://stackoverflow.com/q/7638090/12567365)? And other similar questions? – andrewJames Aug 09 '22 at 16:12
  • Did you attempt to _research your latest problem_? For example: [How do I find the MySQL my.cnf location](https://stackoverflow.com/q/2482234/12567365) – andrewJames Aug 09 '22 at 16:23

0 Answers0