1
我正在嘗試安裝postgresql併爲它在部署上生成一個隨機密碼,僅用於測試。事情是這樣的:在bash中爲postgresql生成隨機密碼
$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 $NAME
sudo -u postgres -H createdb -O $PROJECT $PROJECT
sudo -u postgres -H psql -c "alter user $PROJECT with password '$DBPASS'"
我回來的錯誤是這樣的:
=b3wDxlSbUymho0CmOZ4TgPylLCanKdgJ: command not found /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 ''
任何人都可以請解釋爲什麼會這樣?
謝謝。第二個錯誤是因爲我沒有設置$項目 – Jimmy