Display MySQL Table Data Without Column Name From Command Line

October 16, 2013 | By
| Reply More

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

Filed Under : HOWTOS

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.