gpt4 book ai didi

mysql - 当从文件(批处理模式)重定向 SQL 输入时,为 mysql 命令行获取相同的输出

转载 作者:行者123 更新时间:2023-11-29 07:29:25 28 4
gpt4 key购买 nike

这看起来很简单,但我不知道如何修复它。

这是一个简单的sql脚本:

   select c1 from t1 where c1='notPresent';

我使用交互式 shell 执行它,如下所示:

   mysql -u somebody -psomePassword myDatabase
...
mysql> select c1 from t1 where c1='notPresent';

Empty set (0.00 sec)

现在我执行它:

    mysql -u somebody -psomePassword myDatabase < myFile.sql

输出是:

        mysql: [Warning] Using a password on the command line interface can be insecure.

我知道如何通过在 my.cnf 中保存用户 ID 和密码来抑制此警告,但我也想获得“空集”输出。

与 SQL 更新相同。当脚本来自文件时,它不会像更新的行数那样显示状态。

这是一个更大的应用程序的一部分。我已经将问题缩小到上述情况。

最佳答案

您可以使用三重详细模式在批处理模式下获得完整输出:

echo "show tables" | mysql -v -v -v test 

--------------
show tables
--------------

+--------------------+
| Tables_in_test |
+--------------------+
| ........ |
+--------------------+
2 rows in set (0.00 sec)

Bye

我在查看帮助时发现了这个选项:

mysql --help

...

-v, --verbose Write more. (-v -v -v gives the table output format).

关于mysql - 当从文件(批处理模式)重定向 SQL 输入时,为 mysql 命令行获取相同的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52208263/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com