COOKIES! This blog uses cookies!
I am completely out of control of cookies here, otherwise I would have disabled them (it is controlled by the platform).
If you don't like cookies and being tracked please leave this blog immediately.

Thursday, 31 August 2017

Input redirection with powershell

PowerShell doesn't support input redirection, so it's impossible to do sql file import in usual way without invoking legacy CMD:
PS> mysql dbname < file.sql
At line:1 char:7
+ mysql < .\file.sql
+       ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

    + FullyQualifiedErrorId : RedirectionNotSupported

Luckily it is possible to redirect input by taking file contents, which is, probably, more natural way to do:
PS> Get-Content .\file.sql | mysql dbname

No comments:

Post a Comment