【问题标题】:How to import Data from a MariaDB Dump-File with Windows PowerShell [duplicate]如何使用 Windows PowerShell 从 MariaDB 转储文件导入数据 [重复]
【发布时间】:2022-01-09 19:02:45
【问题描述】:

我正在尝试在 Windows Powershell 中导入一个 dumpfile.sql:

mysql -u root -p --database=database < Backup.sql

但我收到以下错误:

At <script-path>:1 char:34
+ mysql -u root -p --database=database < Backup.sql
+                                      ~ 
The '<' operator is reserved for future use..
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported

如果我试图逃避“

mysql -u root -p --database=database ^< Backup.sql

我只得到所有选项的列表。

问题可能是由于更新到 Windows 11 造成的。

【问题讨论】:

  • 请尝试用英文发布错误信息。顺便说一句:^ 仅在 cmd.exe 中用作转义字符,而不在 PowerShell 中(它是 `,即所谓的反引号)。

标签: powershell io-redirection


【解决方案1】:

您是否尝试过像这样将备份文件复制到mysql exe:

get-content 'Backup.sql' | mysql.exe -u root -p --database=database

另一个在 powershell 中使用 cmd 运行它的选项

& cmd /c "mysql.exe -u root -p --database=database < backup.sql"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-02
    • 2017-05-29
    • 1970-01-01
    • 2020-02-12
    • 2015-10-04
    • 2017-07-19
    相关资源
    最近更新 更多