我需要为我在Docker
图片中构建的PostgreSQL实例创建一个新的超级用户。我似乎无法创建一个,这是我迄今为止尝试过的......
尝试使用“postgres”用户
创建新的超级用户RUN /etc/init.d/postgresql start &&\
sudo su - postgres &&\
sudo psql -U postgres --command "CREATE USER pybossa WITH SUPERUSER PASSWORD 'tester';" &&\
createdb pybossa -O pybossa
> * Starting PostgreSQL 9.3 database server
> ...done.
>psql: FATAL: Peer authentication failed for user "postgres"
“postgres”用户默认没有密码,所以我传入--no-password
RUN /etc/init.d/postgresql start &&\
sudo su - postgres &&\
sudo psql -U postgres --no-password --command "CREATE USER pybossa WITH SUPERUSER PASSWORD 'tester';" &&\
createdb pybossa -O pybossa
> * Starting PostgreSQL 9.3 database server
> ...done.
>psql: FATAL: Peer authentication failed for user "postgres"
所以我传递-h localhost
以禁用每个身份验证
RUN /etc/init.d/postgresql start &&\
sudo su - postgres &&\
sudo psql -U postgres -h localhost --command "CREATE USER pybossa WITH SUPERUSER PASSWORD 'tester';" &&\
createdb pybossa -O pybossa
> * Starting PostgreSQL 9.3 database server
> ...done.
>Password for user postgres:
>psql: fe_sendauth: no password supplied
最后,我尝试使用--no-password
和-h localhost
RUN /etc/init.d/postgresql start &&\
sudo su - postgres &&\
sudo psql -U postgres --no-password -h localhost --command "CREATE USER pybossa WITH SUPERUSER PASSWORD 'tester';" &&\
createdb pybossa -O pybossa
> * Starting PostgreSQL 9.3 database server
> ...done.
>psql: fe_sendauth: no password supplied
非常感谢任何帮助!