【问题标题】:Deploying postgresql with bash - Syntax Error使用 bash 部署 postgresql - 语法错误
【发布时间】:2014-03-13 14:01:58
【问题描述】:

这是我的部署 sn-p:

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 参数,它似乎不接受它。

【问题讨论】:

    标签: linux bash postgresql shell debian


    【解决方案1】:

    问题出在:

    $APP_main
    

    您可能想将_main 附加到变量$APP。而是说:

    ${APP}_main
    

    这将扩展变量$APP 并将_main 添加到它。

    【讨论】:

    • @Rob3 这是一个纯粹的数据库问题。我会说你在另一个线程中问这个!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-09
    • 1970-01-01
    • 2016-07-03
    • 2010-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多