I want to make a command to grant a user in a Postgresql running container certain privileges from command line, without having to access psql manually inside the container. To do this you can use the app commands, here is the documentation: https://www.postgresql.org/docs/8.1/app-psql.html (I've already used other app-commands successfully, for example to create databases with "docker exec -it samplePostgres createdb --username=root --owner=root --encoding=UTF8 sampleDB")
however when using:
docker exec -it samplePSQL psql -d sampleDB -c GRANT SELECT, INSERT, UPDATE ON table TO user;
It outputs the following
psql: warning: extra command-line argument "INSERT," ignored
psql: warning: extra command-line argument "UPDATE" ignored
psql: warning: extra command-line argument "ON" ignored
psql: warning: extra command-line argument "table" ignored
psql: warning: extra command-line argument "TO" ignored
psql: warning: extra command-line argument "user" ignored
psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed:
FATAL: role "SELECT," does not exist
it somehow considers "SELECT" as the user??
of course running it from psql inside the container works like normal.
sampleDB=# GRANT SELECT, INSERT, UPDATE ON table TO user;
GRANT