If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > How do I login as Superuser in Postgresql 9.1

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-07-11, 14:02
hlogoma hlogoma is offline
Registered User
 
Join Date: Oct 2011
Posts: 9
How do I login as Superuser in Postgresql 9.1

Hi,

I have created a new superuser, say Super, and now I want to use Super to create a new database?

I have tried to login as Super with:
su Super
but this does not work, then I thought I would login as postgres and change over to Super as follows:
su postgres
psql -U Super ...but again this fails

Anyone have some insight that they would like to share on this issue?

Thanks for any pointers.

Tom.
Reply With Quote
  #2 (permalink)  
Old 11-07-11, 15:02
hlogoma hlogoma is offline
Registered User
 
Join Date: Oct 2011
Posts: 9
Hi again,

I think I have it,

I logged in as postgres and then from that prompt CREATEDB alloc -O Super and then I went into psql and used \l to list the databases and there was alloc and Super.

The only problem is that I cannot find the switch to define the access privileges and description of the database?

Any help would be appreciated.

Thanks,

Tom.
Reply With Quote
  #3 (permalink)  
Old 11-09-11, 11:50
CarlosinFL CarlosinFL is offline
Registered User
 
Join Date: Oct 2010
Location: Orlando, FL
Posts: 184
Create your user which it appears you already have but confirm using the \du or \dg commands:

Code:
Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication | {}
 test      | Superuser, Create role, Create DB, Replication | {}
Make sure you set a secure password for your new user:

Code:
postgres=# ALTER ROLE test ENCRYPTED PASSWORD 'test123';
ALTER ROLE
**WARNING**
Entering a password in plain text as shown above is not recommended because it's stored in .psql_history file. There's a secure psql command that allows you to do this but I don't remember it.

Now just logout with \q from pgsql client and attempt to login as your new user...

Code:
cmennens@tuna:~$ psql -d postgres -U test -W
Password for user test: 
psql (9.1.1)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

postgres=#
If this doesn't work for you. The issue lies within your hba_conf file and make sure local connections are not set to 'peer' but rather 'md5'.

**EDIT**

To securely change a users password, I found this in the 'psql' man page:

Quote:
\password [USERNAME] securely change the password for a user
It's up to you how you prefer to alter a users password on your server...

Last edited by CarlosinFL; 11-09-11 at 11:54.
Reply With Quote
  #4 (permalink)  
Old 11-09-11, 13:07
hlogoma hlogoma is offline
Registered User
 
Join Date: Oct 2011
Posts: 9
Hi CarlosinFL,

Thanks for your reply to my question and your detailed response which I find informative and helpful.

Thanks again,

Tom.
Reply With Quote
  #5 (permalink)  
Old 11-10-11, 15:21
CarlosinFL CarlosinFL is offline
Registered User
 
Join Date: Oct 2010
Location: Orlando, FL
Posts: 184
No problem at all. It's extremely rare where I can answer questions here since I'm still fairly new to PostgreSQL or RDBMS so I'm more than happy to help out.

-Carlos
Reply With Quote
Reply

Tags
login

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On