Postgres SQL Permissions

I'm running through Lesson 1 again, and I always seem to run into problems when setting up the Postgres user account. I'm not sure how to manage accounts that may already exist, and the documentation online does not seem to address this directly, although maybe I'm just missing it. I'm a novice when it comes to PostgreSQL.

When I use the command 'createdb microblog' I get the error: "createdb: database creation failed: ERROR: permission denied to create database".

I had to create a new user with superuser permissions because for whatever reason I couldn't use my existing user account I had already created, and I was not sure how to access it. Either way, I'm unable to proceed through the lesson.

Does anyone have any advice on getting their bearings with PostgreSQL, particularly managing user accounts (especially if they already exist). The manual just keeps telling me to talk to the admin, but I am the admin. How do I give myself permission to create this database. Thanks!

Sorry You must be a logged in, registered user to answer a question.

Answers

Perhaps a more direct question would be how do I assign the right privileges to a user account to create a database? How can I log into one user account or another?

I followed Kenneth's recommendations for another issue: sudo su postgres dropuser vagrant follow the instructions in the video for creating the vagrant user as a superuser.
Koji on
I'm having trouble understanding where in the "postgres space" I am, and none of my commands seem to work. When I try creating a new user after I 'sudo su postgres' step in your tutorial, it says it could not create the new role because you "must be superuser to create superusers". When I initially sudo into postgres, why am I not by default a superuser? I can't seem to grant myself permissions. I'm missing some steps here i"m sure. Also, once in the postgres space (postgres@precise64) and I enter 'psql' my command lines changes to "postgres=#", but none of the commands I have found seem to register.
Koji on
By default, Postgres only lets you log in, locally, if your user account on the system and your user account in Postgres match (IIRC). You can `sudo su postgres`, then log in as the postgres user with `psql` and then change permissions on the vagrant user if you need.
kennethlove (Staff) on