【问题标题】:How to execute MySQL commands in file from the host to container running MySQL server using Powershell?如何使用 Powershell 从主机到运行 MySQL 服务器的容器执行文件中的 MySQL 命令?
【发布时间】:2021-01-20 08:10:57
【问题描述】:

这些相似但不完全相同

How to execute MySQL command from the host to container running MySQL server?

How to execute mysqldump command from the host machine to a mysql docker container

即使在 Windows 上,这个命令在 Git Bash 中也能很好地工作:

docker exec -i some_docker_container mysql -uroot -psome_password mydb<tables.sql

Powershell 上的相同命令说:

ERROR 1049 (42000): Unknown database 'mydb<tables.sql'

如何将tables.sql 文件作为参数传递? (它包含一些创建表语句)

【问题讨论】:

    标签: mysql docker powershell


    【解决方案1】:

    在 Git Bash 中有效的命令是使用输入重定向。 Powershell 中的 doesn't work&lt; 保留供将来使用。由于 Powershell 不会将 &lt; 解析为重定向,因此它将字符串文字 mydb&lt;tables.sql 作为数据库名称传递。因此,错误消息。

    要执行脚本文件,请使用-e "source script.sql"以批处理方式调用mysql客户端。

    【讨论】:

      猜你喜欢
      • 2015-04-07
      • 2020-11-26
      • 1970-01-01
      • 1970-01-01
      • 2021-05-12
      • 2015-10-21
      • 1970-01-01
      • 1970-01-01
      • 2021-03-03
      相关资源
      最近更新 更多