I would like to import a 350MB MySQL .sql file on a Windows 7 machine. I usually do this by using
mysql -uuser -p -e "source c:/path/to/file.sql" database
since < doesn’t work in Powershell.
My .sql file has an error in it this time. I’d prefer to just skip the bad row and continue the import. How can I force the import to continue on Windows?
On a unix/linux based system, I could use
mysql --force ... < file.sql
but –force doesn’t seem to work with the -e “source …” command (understandably so).
Thanks,
Mike
You’re probably going to have to have Powershell execute this in the standard console in order to use
<properly. Technically you could useget-contentand pipe the output tomysql, but I’ve always found that to be slow, and it somehow still keeps the file contents in memory of the Powershell session.This is how I would execute it from the Powershell prompt (changed file path to include spaces to demonstrate inner quotes, just in case):
[GC]::collect()would apparently clear it up the memory, but you can’t do that until after it’s done anyway. When it comes tomysqlandmysqldump, I don’t bother with Powershell. The default encoding used in>is Unicode, making dump files twice as big out of Powershell as out ofcmdunless you remember to write| out-file dump.sql -enc asciiinstead of> dump.sql.