Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use Windows 7 on my own home computer. I have installed PostgreSQL and now I would like to create an database.

I tried with createdb mydatabase but I got this error message:

createdb: could not connect to database postgres: FATAL: role "Jonas" does
not exist

I have also tried to create a role "Jonas" with createuser Jonas but I got the same error, even if I was logged in as Administrator in PowerShell.

How can I create a PostgreSQL database on my Windows 7 machine?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

http://www.postgresql.org/docs/8.1/static/tutorial-createdb.html

Another response could be this:

createdb: could not connect to database postgres: FATAL:  user "joe" does not
exist

where your own login name is mentioned. This will happen if the administrator has not created a PostgreSQL user account for you. (PostgreSQL user accounts are distinct from operating system user accounts.) If you are the administrator, see Chapter 18 for help creating accounts. You will need to become the operating system user under which PostgreSQL was installed (usually postgres) to create the first user account.

share|improve this answer
1  
I tried to start PowerShell as Administrator and then execute createuser Jonas but I got the same error message. –  Jonas Dec 10 '10 at 22:34
    
Did you try to start PowerShell as postgres? –  ta.speot.is Dec 10 '10 at 22:42
    
No, how can I do that? I asked a related question to solve this, but that only works for Administrator. –  Jonas Dec 10 '10 at 22:52
    
It worked when I started PowerShell with runas /user:ComputerName\postgres powershell and then executed createuser Jonas –  Jonas Dec 10 '10 at 23:34

From http://www.postgresql.org/docs/8.1/static/tutorial-createdb.html

It could also be that you were assigned a PostgreSQL user name that is different from your operating system user name; in that case you need to use the -U switch or set the PGUSER environment variable to specify your PostgreSQL user name.

I met the same problem, now I do it with

createdb -U postgres dbname
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.