What are the best ways to view MySQL query results with many columns in command line?

I’m working with a database table that has lots of columns. When I run a query like SELECT * FROM my_data_table; in the MySQL command line, the output becomes really messy because there are too many columns to fit nicely on the screen.

The problem is that all the column data wraps to new lines and it becomes impossible to match up the headers with the actual values. Everything just looks jumbled together.

I need to find terminal-based solutions for this issue. I don’t want to use any web interfaces or GUI tools. Just looking for command line tricks or methods to make the output more readable when dealing with wide result sets.

For viewing wide query results in the MySQL command line, consider using the ‘\G’ command instead of a semicolon. This displays results vertically as key-value pairs, making it easier to read without wrapping issues. Additionally, you can pipe the output through ‘less -S’ to prevent line wrapping and allow horizontal scrolling. Setting the pager with ‘pager less -S’ in the MySQL client also helps. If the table is extremely wide, exporting to a CSV file using ‘SELECT … INTO OUTFILE’ and using column-aware tools may be beneficial, provided you have file system access.