Does anyone know of a good tool to use from the shell to query the database and get intelligible results?
On the command line, from SSH, I want to query the database using mysql
but the results are pretty much unreadable because there is no formatting for the terminal screen.
If I run the following it is vary hard to make sense of the results.
use mydb; select * from db3_settings;
I know I could use phpMyAdmin or the MySQLCC but I'm looking for a command-line solution.
The Output is located at the bottom of MySQL Workbench. Its select box includes the Action Output , History Output , and Text Output options.
The EXIT or QUIT commands take you returned to windows from MySQL command line tool.
To show the schema, we can use the DESC command. This gives the description about the table structure.
A little publicized, but exceedingly useful feature of the MySQL command line client is the \G modifier. It formats the query output nicely, so you can read through it easier. To use it, you just replace the semi-colon at the end of the query with '\G'.
You can obtain a vertically formatted output with \G
.
This is the standard output:
mysql> select * from tblSettings; +-----------+----------------+---------------------+ | settingid | settingname | settingvalue | +-----------+----------------+---------------------+ | 1 | maxttl | 30 | | 2 | traceroutepath | /usr/bin/traceroute | | 3 | alertemail | [email protected] | +-----------+----------------+---------------------+ 3 rows in set (0.00 sec)
And this is what the output looks like with \G
:
mysql> select * from tblSettings \G; *************************** 1. row *************************** settingid: 1 settingname: maxttl settingvalue: 30 *************************** 2. row *************************** settingid: 2 settingname: traceroutepath settingvalue: /usr/bin/traceroute *************************** 3. row *************************** settingid: 3 settingname: alertemail settingvalue: [email protected] 3 rows in set (0.00 sec)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With