2

I'm passing some commands to mysql in bash via ssh, and want to see not only the query results, but also the mysql status message returned in stdout.

For instance, when I send:

mysql --defaults-file=~/.my.cnf -e "SELECT orderdate FROM marketdata LIMIT 1;"

I see the following output:

+------------+
| orderdate  |
+------------+
| 2019-04-04 |
+------------+

If I'm logged in to the server directly and run the command: SELECT orderdate FROM marketdata LIMIT 1; I see the following output:

+------------+
| orderdate  |
+------------+
| 2019-04-04 |
+------------+
1 row in set (0.00 sec)

How do I go about seeing the mysql status message displayed after each query "1 row in set (0.00 sec)" when I'm sending commands via ssh, as well?

enharmonic
  • 1,800
  • 15
  • 30
  • 1
    See: [How to get number of rows affected, while executing MySQL query from bash?](https://stackoverflow.com/q/1083866/3776858) – Cyrus Apr 22 '19 at 18:09

1 Answers1

3

You can pass the -v flag to get more verbose output.

In your case I think passing -v twice will give you the level of verbosity you want.

For example:

mysql --defaults-file=~/.my.cnf -vve "SELECT orderdate FROM marketdata LIMIT 1;"
Ike Walker
  • 64,401
  • 14
  • 110
  • 109