First I run the command
sudo su _postgres
, then I run the commandcreate role mixeddrinks with createdb login password 'password1'
You're mixing up shell commands and the psql
command line.
If you want to use SQL, you need to use the psql
command. sudo su _postgres
is an inefficient way of getting a unix command shell as the _postgres
user. It doesn't give you an SQL shell. You can run unix commands like psql
, createuser
, etc from the unix command shell. You can tell you're at the command shell because the prompt looks something like:
postgres$
If you want an SQL shell, so you can run commands like CREATE USER
, etc, you need to run psql
. If you want a superuser SQL shell, that'd be something like:
sudo -u _postgres psql
This will give you a prompt like:
postgres=#
where you can run SQL commands. Remember that SQL commands end with a semicolon.
postgres=# create role mixeddrinks with createdb login password 'password1';