Friday, July 27, 2012

Postgresql: create first user and first database createdb createuser

Here I have explained how to create first database and first user for postgresql database. If you are reading article then am sure that you are newbie with postgresql.

As we need some user to create database we will create user first

1> Creating user

To create user we must login to some existing user. The existing user is postgres.
As postgres doesnt have password we must login using root.

so first login in shell as root.

domnique@domniquepc:~$sudo  su

Then from root, login into postgres

root@domniquepc:~#sudo - postgres

now Create  new user here using command createuser,

postgres@domniquepc:~$ createuser domnique


You will be asked if you are a superuser, in my case I had said yes, as I was the only one to access this computer. Do not know other options

2> Create Database

After creating new user it is much simple to create new database, I had used following command which  will set me as a owner of database

domnique@domniquepc:~$ createdb  mingle

Once you create the fist user, then using this user later you could create many databases and new users.