How to Hide Column Name (Heading) from MySQL Table
Abstract: MySQL Query Sentence. The command ismysql -u root --password=qwe123 -s -N -e "SELECT host FROM mysql.user
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.
1) Display common table dataSyntax :
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 or in other words it will hide 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