Display MySQL Table Data without Column Name from Command Line

This article illustrates 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 the 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

This command will get table column information without column name.

Syntax :

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

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

Bobbin Zachariah 5:01 am

Comments

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

All comments are subject to moderation.