当我在MySQL 5.7客户机中以交互方式运行SQL语句时,它会告诉我查询运行了多长时间:
mysql> select now();
--------------
select now()
--------------
+---------------------+
| now() |
+---------------------+
| 2018-03-09 14:27:42 |
+---------------------+
1 row in set (0.07 sec)在本例中,它运行了0.07秒。
但是,当我通过脚本运行相同的SQL语句时,输出不包括语句所用的时间。
>mysql -f -v --table -u myuser -pmypassword -h myhost mydb < test.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
--------------
select now()
--------------
+---------------------+
| now() |
+---------------------+
| 2018-03-09 14:31:00 |
+---------------------+我如何从脚本中运行一个SQL语句,并且仍然能够获得它使用MySQL 5.7客户机运行的时间长度?
谢谢!鲍比
发布于 2018-03-09 22:48:34
您可以在mysql命令中使用-vvv。
mysql -f -vvv --table -u myuser -pmypassword -h myhost mydb < test.sql
> mysql -vvv < mysql.sql
--------------
select now()
--------------
+---------------------+
| now() |
+---------------------+
| 2018-03-10 04:08:33 |
+---------------------+
1 row in set (0.00 sec)
Bye希望它能满足你的要求:)
https://dba.stackexchange.com/questions/199851
复制相似问题