The second method is to start a psql session and go into the template1 database. This involves the command:

   psql template1
   

This message should appear:

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit
   

You can now use the PostgreSQL create user command to create a superuser. The advantage of creating a user here is that you can specify additional attributes to tag onto this user. For instance, you can give this user a password, or limit this user from creating databases. The options available for the CREATE USER command is discussed in detail at the User Management chapter.

This is an example of how to create as super user when logged in a database:

Example 8-1. Creating a Postgres Superuser

    CREATE USER superuser CREATEUSER CREATEDB;
  

Note superuser
 

The properties that make this user a super user are create user and create database. If only one of these properties are specified, then this user is a normal PostgreSQL database user.

Help us make a better book, leave feedback. (http://www.opendocspublishing.com/entry.lxp?lxpe=92)