0

I'm trying to import about 20 .csv files into MySQL and I'm fed up with doing it via phpmyadmin's import gui.

Is there a way to do this by batch without typing on the command line? i.e. a script that will run when double clicked (Windows). What I want is:

  1. I have files like porsche.csv, ferrari.csv etc
  2. I want to import each of these into tables with the same name (i.e. porsche, ferrari)
  3. Empty the table before importing the text file (using delete flag). How does it handle new fields?
  4. Ignore first line (header).

From what I've gathered so far: we use mysqlimport: http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html

I'll try to fiddle around with the options and see if I can get something working.

1
  • 1
    Clickable from a Mac desktop? Windows? BeOS? :) mysqlimport would work nicely, really it's a question of what scripts are available in your environment. Commented Mar 14, 2013 at 15:30

1 Answer 1

0

On Windows, the easiest way is to use a batch script.

Read the documentation on available options.

The batch script would look something like:

@echo off
cd C:\Program Files\MySQL\MySQL Workbench 5.2 CE\

mysqlimport ...

Other related questions:

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

2 Comments

Trying to do a mysqlimport --local "C:\Users\Desktop\dude.csv" but the file cannot be found. Are we limited to the `C:\Program Files\MySQL\MySQL Workbench 5.2 CE` directory?
@meiryo Not at all. That just points to the directory that contains your mysql instance.

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.