psql create user SUPER USER WITH password throwing syntax error message

5.1k views Asked by At

I am trying to create a SUPERUSER PostgreSQL user with an encrypted password using psql.

CREATE USER my_username SUPERUSER WITH ENCRYPTED PASSWORD 'MYPASS';

However the above command results in the following error

ERROR:  syntax error at or near "WITH"
LINE 1: CREATE USER my_username SUPERUSER WITH ENCRYPTED PASSWORD 'M...

But the following command works fine

CREATE USER my_username WITH ENCRYPTED PASSWORD 'MYPASS';

I am using PostgreSQL 13, what am I doing wrong?

1

There are 1 answers

0
Adrian Klaver On BEST ANSWER

From here:

https://www.postgresql.org/docs/current/sql-createuser.html

The correct form is:

CREATE USER my_username WITH SUPERUSER ENCRYPTED PASSWORD 'MYPASS';