Execute mysql commands without logging in to the database
1. Implemented through echo (this is more common)
Echo "show databases;" | mysql-uroot-pqwe123-S / data/3307/mysql.sock
Tip: this method is suitable for situations where there are few single-line strings.
two。 Realized by mysql-e parameter
Mysql-u root-pqwe123-S / data1/3307/mysql.sock-e "show databases;"
3. Implemented through cat (this method is not used much)
Cat | mysql-uroot-pqwe123-S / data/3307/mysql.sock