change with mysql_exec "show tables;" try fixed mysql --defaults-file=/dev/stdin "${opts}" -e "use ${mysql_database}; ${query}"