我下载了postgres:https://hub.docker.com/r/library/postgres/的docker容器,并执行了以下操作:
$ docker run --name satgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
satgres | "docker-entrypoint.s…" | 5 seconds ago | Up 6 seconds | 0.0.0.0:5432->5432/tcp | satgres
$ docker exec -it c8f1b22cc41e /bin/bash
# psql -U postgres
psql (10.1)
postgres=# CREATE DATABASE mytest;
postgres=# \password postgres
postgres=# CREATE ROLE ming WITH LOGIN PASSWORD 'pass1234';
postgres=# ALTER ROLE ming CREATEDB;
postgres=# CREATE DATABASE sjk;
postgres=# GRANT ALL PRIVILEGES ON DATABASE youtube TO ming;
postgres=# \connect sjk
youtube=# ALTER ROLE ming lOGIN;
我的计划是在Django的 docker 上使用这个数据库,所以首先我想判断一下我是否可以连接,但我不能.
$ psql -h localhost -p 5432 -U postgres
$ psql: FATAL: role "postgres" does not exist
$ psql -h localhost -p 5432 -U ming
$ psql: FATAL: role "ming" does not exist
我对PSequal也这么做.应用程序,也是这么说的,
为什么我会犯这个错误?这个角色存在,或者至少在我看来...