Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行包含postgresql脚本的bash脚本失败_Bash_Postgresql - Fatal编程技术网

运行包含postgresql脚本的bash脚本失败

运行包含postgresql脚本的bash脚本失败,bash,postgresql,Bash,Postgresql,我已经创建了包含sql脚本(postgresql)的bash脚本,但失败了 文件所有者:postgres:postgres with 777(chmod),但当我使用“/bash1.sh”执行时,错误:psql:FATAL:角色“postgres”不存在 bash脚本: #!/bin/sh THE_DATABASE=epolicy MY_TABLE=hpx_sms psql ${THE_DATABASE} <<THE_END SELECT * FROM ${MY_TABLE}

我已经创建了包含sql脚本(postgresql)的bash脚本,但失败了

文件所有者:postgres:postgres with 777(chmod),但当我使用“/bash1.sh”执行时,错误:psql:FATAL:角色“postgres”不存在

bash脚本:

#!/bin/sh

THE_DATABASE=epolicy
MY_TABLE=hpx_sms

psql ${THE_DATABASE} <<THE_END
  SELECT * FROM ${MY_TABLE};
THE_END
#/垃圾箱/垃圾箱
_数据库=epolicy
MY_TABLE=hpx_sms

psql${THE_DATABASE}的可能副本您可以从命令行访问psql吗?您可能希望找到登录数据库的适当用户。这不是bash脚本问题,如果您可以修复此问题:
psql epolicy
,您也可以修复bash脚本。谢谢,问题解决了,我使用postgres用户执行,而不是root或padmin