对于在bash脚本中使用以下mysql命令出错的地方感到困惑,以HTML格式获取SELECT语句。
#!/bin/bash
dbhost="localhost"
dbname="unicentaopos"
dbuser="user"
dbpass="pass"
mysql -h $dbhost -u $dbuser -p $dbpass -H -e "SELECT NOW();" $dbname > /home/imperial/.scripts/test.txt
除了出于明显原因的凭据外,其他所有内容都与我的脚本相同。我也尝试过将vars硬编码到命令中-同样的结果。
我看不到我所做的任何事情,但是生成的文本文件仅包含mysql使用选项:
mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using EditLine wrapper
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
etc etc etc etc.....
谁能告诉我怎么了?
答案 0 :(得分:1)
是否正确访问了dbhost变量? #dbhost-> $ dbhost