tags:

views:

75

answers:

1

It's basically this - I was used to using mysql < dbfile.sql to restore a database dump created with mysqldump. Then I saw there is mysqlimport, with no reference to the other way. The arguments of both CLIs look similar. So, what's the actual difference? (And is there any)

+2  A: 

My understanding is that mysqlimport is the equivalent of LOAD DATA INFILE, so the data to be loaded must be e.g. in CSV format, not the usual output of mysqldump.

Mirko Nasato
hm, I can see from the docs that mysqldump can export csv, and for mysqlimport (and LOAD DATA INFILE) it isn't explicitly mentioned that the format must be CSV.
Bozho
Yes, but the point is that `mysql < dump.sql` executes SQL statements, while `mysqlimport` reads raw data in some delimited text format, separated by commas, tabs, or similar. So `mysqlimport` is faster, but data needs to be in the expected format, and tables must already exist.Exporting/importing as SQL statements is more flexible (can include CREATE TABLE etc) and safer (no risk of getting columns in wrong order). Which is why it's the default format generated by `mysqldump` I guess.
Mirko Nasato