MySQLDump one INSERT statement for each data row


Translate

with the following statement:

mysqldump --complete-insert --lock-all-tables --no-create-db 
--no-create-info --extended-insert --password=XXX -u XXX 
--dump-date yyy > yyy_dataOnly.sql

I get INSERT statements like the following:

INSERT INTO `table` VALUES (1,'something'),(2,'anything'),(3,'everything');

What I need in my case is something like this:

INSERT INTO `table` VALUES (1,'something');
INSERT INTO `table` VALUES (2,'anything');
INSERT INTO `table` VALUES (3,'everything');

Is there a way to tell "mysqldump" to create a new INSERT statement for each row? Thanks for your help!


All Answers
  • Translate

    Use:

    mysqldump --extended-insert=FALSE 
    

    Be aware that multiple inserts will be slower than one big insert.


  • Translate

    In newer versions change was made to the flags: from the documentation:

    --extended-insert, -e

    Write INSERT statements using multiple-row syntax that includes several VALUES lists. This results in a smaller dump file and speeds up inserts when the file is reloaded.

    --opt

    This option, enabled by default, is shorthand for the combination of --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset. It gives a fast dump operation and produces a dump file that can be reloaded into a MySQL server quickly.

    Because the --opt option is enabled by default, you only specify its converse, the --skip-opt to turn off several default settings. See the discussion of mysqldump option groups for information about selectively enabling or disabling a subset of the options affected by --opt.

    --skip-extended-insert

    Turn off extended-insert