5
我在PHP腳本中創建bash命令。內置命令如:psql - 角色根目錄不存在
su postgres -c "for tbl in `psql -qAt -c \"select tablename from pg_tables where schemaname = 'public';\" demodoo` ;do psql -c \"alter table $tbl owner to postgres\" demodoo ;done "
當我嘗試在shell中運行這個命令,我得到這個錯誤:
psql: FATAL: role "root" does not exist
這是爲什麼發生的歷史,而我在postgres用戶執行命令?
感謝 乾杯,
編輯 我更改命令以
sudo -u postgres for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" demodoo` ;do psql -c "alter table $tbl owner to postgres" demodoo ;done
但現在我得到另一個錯誤,我無法理解的起源:
-bash: syntax error near unexpected token `do'
檢查此鏈接:http://serverfault.com/questions/601140/whats-the-difference-between-sudo-su-postgres-and-sudo-u-postgres – 2014-11-25 10:46:28
謝謝,我在閱讀帖子後編輯了我的問題,但我得到一個錯誤 – renard 2014-11-25 11:07:42
此鏈接可能會幫助你:http://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist – 2014-11-25 11:12:01