Permission denied to create database

After a fresh new installation of PerconaSQL operator and database cluster a new database can not be created using provided user and password.
Console output after Percona PostgreSQL deployment:

To get a PostgreSQL prompt inside your new cluster you can run:

  POSTGRES_USER=$(kubectl -n postgre get secrets postgresql-pg-db-pguser-secret -o jsonpath="{.data.username}" | base64 --decode)
  POSTGRES_PASSWORD=$(kubectl -n postgre get secrets postgresql-pg-db-pguser-secret -o jsonpath="{.data.password}" | base64 --decode)

And then
  $ kubectl run -i --rm --tty percona-client --image=perconalab/percona-distribution-postgresql:13.2 --restart=Never \
  -- psql "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresql-pg-db-pgbouncer.postgre.svc.cluster.local/pgdb"

I do exactly as instruction says:

$ export POSTGRES_USER=$(kubectl -n postgre get secrets postgresql-pg-db-pguser-secret -o jsonpath="{.data.username}" | base64 --decode)
$ export POSTGRES_PASSWORD=$(kubectl -n postgre get secrets postgresql-pg-db-pguser-secret -o jsonpath="{.data.password}" | base64 --decode)
$ kubectl run -i --rm --tty percona-client --image=perconalab/percona-distribution-postgresql:13.2 --restart=Never \
>   -- psql "postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgresql-pg-db-pgbouncer.postgre.svc.cluster.local/pgdb"
If you don't see a command prompt, try pressing enter.
pgdb=> CREATE DATABASE test1;
ERROR:  permission denied to create database

Why the new Percona user does not have permissions to even create a new database?
How to fix this?

1 Like

pguser is an unprivileged user that cannot create databases, but can operate within pgdb database.

I see you also created this topic for postgres user - Postgres user: no such user. What user has permissions to create a database? - #2 by spronin

I hope my answer helps there.

1 Like