0

My psql does not open. Weirdly enough. I've created a user "Ben" through logging using psql -U postgres that lets me open PSQL and I run a command

CREATE USER Ben WITH PASSWORD '123';

After I do that it says ERROR: role "ben" already exists

But when I run psql it throws me psql: FATAL: role "Ben" does not exist

12
  • Case matters. Either be consistent everywhere and use lowercase or wrap it in double quotes. Commented Nov 29, 2016 at 0:01
  • Ahhh, would it resolve if I DROP User Ben; then recreate like CREATE USER Ben WITH PASSWORD '123'; Commented Nov 29, 2016 at 0:06
  • How Ben is different to Ben though? Commented Nov 29, 2016 at 0:06
  • They're the same thing? Commented Nov 29, 2016 at 0:07
  • I don't see the difference between Ben and Ben. Commented Nov 29, 2016 at 0:07

1 Answer 1

1

When you issue an SQL command like this:

CREATE USER Ben WITH PASSWORD '123';

identifiers within this command (such as the user name) are folded to lower case. So the user is actually created as 'ben'.

When you issue a shell command such as:

psql -U Ben mydatabase

then the identifier case is preserved, making it case sensitive.

If you really want the user name capitalized, then double quote it in SQL, like this:

CREATE USER "Ben" WITH PASSWORD '123';

Otherwise leave it all lower case and connect with:

psql -U ben mydatabase

See: Identifiers & Keywords in the manual

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.