2

How can I import multiple files(.csv, .sql etc) into xampp mysql database ?

I am using Xampp and windows XP.

If I need to write command prompt type command, please tell in details where to find the command prompt type screen and so on.

Istiaque Ahmed
  • 6,072
  • 24
  • 75
  • 141
  • usually you only put the files names or paths into mysql... what are you trying to do? – jribeiro Oct 27 '11 at 10:15
  • i uploaded 25 files from a directory to the localhost mysql database using the built-in graphical interface . I just want to know the way.Do u mean to write code? – Istiaque Ahmed Oct 27 '11 at 10:24

2 Answers2

0

The SQL files you can execute with MySQL command-line tool, e.g. -

shell> mysql db_name < script.sql

Load data from the CSV file into specified table you can with LOAD DATA INFILE statement.

If you do not have access to mysql client, then try dbForge Studio for MySQL. Free express edition allows to execute SQL scripts and import data from the CSV file without limitations.

Devart
  • 119,203
  • 23
  • 166
  • 186
0

This topic has been covered already, in its parts.

  1. to import a CSV you can check this question, which will lead you to use:

LOAD DATA INFILE yourfile.csv

or if you need to update some data that is already on the database you can relate to a question I answered not long ago (and possibly other answers on stackoverflow).

You may execute this statement in the mysql prompt with mysql -u user -p -h localhost -D database (learn how to find the path to mysql.exe in your XAMMP using this question) or using some other way, such as your scripting/programming language of choice together with mysql connectors/libraries.

You may also use the mysqlimport.exe command (it'll be in the same folder as your mysql binary).

  1. To import a sql file you can take a look at this question. You will essentially just copy the file contents into the mysql prompt, which is usually done with input redirection on the console:

C:>mysql -u user -p -h localhost -D database -o < yoursqlfile.sql

I hope that besides answering your question i might also have introduced you to the fact that with thousands(?) of questions in stackoverflow you are very likely to find the answers to your doubts by searching the questions database, possibly faster than asking your own new question.

Community
  • 1
  • 1
Bruno Flávio
  • 778
  • 10
  • 27
  • I was looking for the way to upload MULTIPLE files TOGETHER, not just one file at a time. I am yet to get any solution. I am aware of the rich question-answer repository of SOF. Still thank you. – Istiaque Ahmed Oct 28 '11 at 04:52
  • very well then, so you want to upload MULTIPLE files together, yes it's possible, search for "[import multiple csv files](http://stackoverflow.com/search?q=%5Bmysql%5D+import+multiple+csv+files)", and for "[import multiple csv files](http://stackoverflow.com/search?q=%5Bmysql%5D+import+multiple+sql+files)" for sql files. Keep in mind that inserting all the csv files at once might lead into problems: you need to specify the database and table where the contents will be placed, unless they are all going to the same table. and sql files the same if they don't specify the database. – Bruno Flávio Oct 28 '11 at 10:12
  • On the other hand, if you wish to import **multiple** files and **multiple file formats** at once i don't know of a solution. – Bruno Flávio Oct 28 '11 at 10:16