这是我的部署片段:
APP="test"
DBPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
sudo -u postgres -H createuser --no-createrole --no-superuser --no-createdb $APP_main
sudo -u postgres -H createdb -O $APP_main $APP_main
sudo -u postgres -H psql -c "alter user $APP_main with password '$DBPASS'"
这是我的注销:
/usr/lib/postgresql/9.1/bin/createdb: option requires an argument -- 'O'
Try "createdb --help" for more information.
ERROR: syntax error at or near "with password"
LINE 1: alter user with password 'hCGCly4ZVfu42Dr956ncypuf6mt0lBiY'
谁能解释一下哪里出了问题?我已经指定了 O 参数,它似乎不接受它。
最佳答案
问题出在:
$APP_main
您可能想将 _main
附加到变量 $APP
。而是说:
${APP}_main
这将扩展变量 $APP
并将 _main
附加到它。
关于linux - 使用 bash 部署 postgresql - 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22380999/