There are two ways to execute SQL commands under the command line. The first is to use the "-e" parameter to specify the SQL statement to be executed, and the second is to use the pipeline. Syntax and example: 1. MYSQL_HOME/bin/mysql-u username-p password-D database name-e "SQL Statement"/usr/local/mysql/bin/mysql-uroot-p123456-Dmysql-e "selecthost, userfromu
There are two ways to execute SQL commands under the command line. The first is to use the "-e" parameter to specify the SQL statement to be executed, and the second is to use the pipeline. Syntax and example:
1. MYSQL_HOME/bin/mysql-u username-p password-D database name-e "SQL Statement"/usr/local/mysql/bin/mysql-uroot-p123456-Dmysql- e "select host, user from user "; 2. echo" SQL statement "| MYSQL_HOME/bin/mysql-u user name-p password-D database name echo" select host, user from user "|/usr/local/mysql/bin/mysql-uroot-p123456-Dmysql
The preceding command execution result is as follows. The results are different.