How can I create a database in PostgreSQL on Windows 7?
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?
Solution 1:
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.
Solution 2:
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