OutOfMemory Exception duing mysqldump I am trying to add a slave MySQL server to an existing server. I ran the following mysqldump on the master to prepare the data for the slave initially.

mysqldump.exe -u ... -p... --single-transaction --flush-logs --skip-lock-tables --master-data=2 &gt; all-dbs.sql


But after a while, it gave the following error;

Program 'mysqldump.exe' failed to run: Exception of type 'System.OutOfMemoryException' was thrown.At line:1 char:1
+ .\mysqldump.exe -u ... -p... --skip-lock-tables --single-tran ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ .\mysqldump.exe -u ... -p... --skip-lock-tables --single-tran ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed


The master MySQL server has 3.5GB memory, and the data is about 5GB.
It is running MySQL 5.7.
Any help would be greatly appreciated.  Thanks.
Just like  Michael - sqlbot suggested, --quick would help. Official MySQL Doc states:


  --quick, -q
  
  This option is useful for dumping large tables. It forces mysqldump to
  retrieve rows for a table from the server a row at a time rather than
  retrieving the entire row set and buffering it in memory before
  writing it out.


http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_quick

Regarding the PowerShell issue, there's a note on MySQL Doc:


  Note:
  
  A dump made using PowerShell on Windows with output redirection
  creates a file that has UTF-16 encoding:
  
  shell&gt; mysqldump [options] &gt; dump.sql 
  
  However, UTF-16 is not permitted
  as a connection character set (see Section 11.1.4, “Connection
  Character Sets and Collations”), so the dump file will not load
  correctly. To work around this issue, use the --result-file option,
  which creates the output in ASCII format:

shell&gt; mysqldump [options] --result-file=dump.sql



http://dev.mysql.com/doc/refman/5.7/en/mysqldump.html