Display MySQL Table Data Without Column Name From Command Line

This article illustrate a trick to use Mysql command to get your MySQL table data and display table data without column name. You can use this command to get MySQL data in command line and it would be helpful when you write shell scripts.

mysql table display

1. Display common table data

Syntax :

mysql -u $user --password=$password -e "MySQL Query Sentence"

You can specify the the user name ,password , MySQL Query sentence.

For example, the user name is root, password is 123qwe, sentence is "SELECT host FROM mysql.user;".

The command is:

mysql -u root --password=123qwe -e “SELECT host FROM mysql.user;”

The output is:

+-----------------+
| host |
+-----------------+
| % |
| 127.0.0.1 |
| ::1 |
| linux-odv8.site |
| linux-odv8.site |
| linux-odv8.site |
| localhost |
| localhost |
| localhost |
| localhost |
+-----------------+

2. Display table data without column name

Syntax :

mysql -u $user --password=$password -s -N -e "MySQL Query Sentence"

This command will get table column information without column name.
.
For example, set the user name, password, MySQL Query Sentence.

The command is:

mysql -u root --password=qwe123 -s -N -e "SELECT host FROM mysql.user;"

The output is:

%
127.0.0.1
::1
linux-odv8.site
linux-odv8.site
linux-odv8.site
localhost
localhost
localhost
localhost

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.