#!/bin/bashsql='show databases'
result=`mysql -uroot -pengine2user -h127.0.0.1 -e "${sql}"` #一定要加双引号 “”“”
echo $result
参考: https://blog.csdn.net/long12310225/article/details/77521957