0

When I run a SQL statement interactively in a MySQL 5.7 client it tells me how long the query ran:

mysql> select now();
--------------
select now()
--------------

+---------------------+
| now()               |
+---------------------+
| 2018-03-09 14:27:42 |
+---------------------+
1 row in set (0.07 sec)

In this case it ran for 0.07 seconds.

But when I run the same SQL statement through a script the output does not include the time the statement took.

>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 |
+---------------------+

How can I run a SQL statement from a script and still get back the length of time that it ran using the MySQL 5.7 client?

Thanks! Bobby

2
  • 1
    Does adding more verbosity -v -v -v -v help? Commented Mar 9, 2018 at 22:33
  • 1
    I thought I had looked at the -v flag but didn't read the manual carefully enough to see that you could have it multiple times. I'm new to mysql. Thanks for saving me time. Commented Mar 12, 2018 at 15:57

1 Answer 1

2

You can use -vvv with mysql command.

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

Hope it will fulfill your requirement :)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.