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.

2
  • usually you only put the files names or paths into mysql... what are you trying to do? Commented Oct 27, 2011 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? Commented Oct 27, 2011 at 10:24

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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.
In *nix you could use a 'cat' command to concatenate the files, cat file1.CSV file2.CSV.
Try this command - 'copy /a doc1.txt + doc2.txt doc3.txt' - computerhope.com/copyhlp.htm
using XAMPP, where can I find the shell ?
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.

3 Comments

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.
very well then, so you want to upload MULTIPLE files together, yes it's possible, search for "import multiple csv files", and for "import multiple csv 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.
On the other hand, if you wish to import multiple files and multiple file formats at once i don't know of a solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.