如何使用 Windows PowerShell 从 MariaDB 转储文件导入数据[重复]

问题描述 投票:0回答:1

我正在尝试使用以下命令在 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而出现问题。

powershell io-redirection
1个回答
2
投票

您是否尝试将备份文件通过管道传输到

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"
© www.soinside.com 2019 - 2024. All rights reserved.