Use shell commands to operate databases and shell command Databases
You can use the-e parameter of mysql to perform various SQL operations (create, delete, add, delete, modify, and query ).
Usage
Mysql-uxxx-pxxx-e "mysql Command"
You can also use the following statement:
Mysql-e-uxxx-pxxx "mysql Command"
Practice
[Root @ iZwz99qnmldt4n744noo9gZ ~] # Mysql-e "show databases;"-uroot-ppenghui110> test.txt [root @ iZwz99qnmldt4n744noo9gZ ~] # Lsdatabases_backup_20170411172702 lnmp1.3-full lnmp-install.log test.txt [root @ iZwz99qnmldt4n744noo9gZ ~] # Cat test.txt Databaseinformation_schemablogmysqlperformance_schemaquestionwordpressyii2 [root @ iZwz99qnmldt4n744noo9gZ ~] # Mysql-uroot-ppenghui110-e "show databases;"> a.txt [root @ iZwz99qnmldt4n744noo9gZ ~] # Cat a.txt Databaseinformation_schemablogmysqlperformance_schemaquestionwordpressyii2
Reference: http://blog.csdn.net/feeltouch/article/details/46643065