How to view large rows with many columns in mysql cli client

It’s hard to view long column names in mysql CLI as the screen wraps them and then instead of a table spanning horizontally , half the columns are stacked over each other , making it confusing to look at .

There are two ways to make it pretty –

1. Horizontally Scrollable Paged View

Something like the below output of a select query

To make it more readable we can use the following command

mysql > pager less -SFX;
mysql > select * from databasename.table;

and then you can use right and left arrow keys to navigate the whole lengthy row and to get out of that view you can press q

It looks something like the following GIF

If you wish to reset this behaviour use –

mysql> nopager;

2. Vertical Columns View

You can also just add a \G at end of your query to get a vertical output like the following

SELECT * FROM tablename LIMIT 2 \G

Bonus: Third Party Alternative to MySQL CLI

You can also use the following CLI tools to view/work with MySQL in a more efficient manner

It is based on python and has lots of features , also available on Windows, Mac, Linux so give it a try !

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.