Thread: New role, no database
Hello, I have a question for which I am unable to find an answer in the documentation, if y'all don't mind, I will ask here and hope for an answer. After installing PostgreSQL and logging in as the admin user of postgres, I have created a new user with the CREATEDB privilege. How does that user log in for the first time to create a DB? Am I required to create a default user DB when I create the user, or is there a way to log in with no default DB? TIA, Melvin
Melvin Call escribió: > Hello, > > I have a question for which I am unable to find an answer in the > documentation, if y'all don't mind, I will ask here and hope for an > answer. > > After installing PostgreSQL and logging in as the admin user of > postgres, I have created a new user with the CREATEDB privilege. How > does that user log in for the first time to create a DB? Am I required > to create a default user DB when I create the user, or is there a way > to log in with no default DB? They can use the "postgres" database for this. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
On Thu, May 23, 2013 at 3:01 PM, Melvin Call <melvincall979@gmail.com> wrote: > Hello, > > I have a question for which I am unable to find an answer in the > documentation, if y'all don't mind, I will ask here and hope for an > answer. > > After installing PostgreSQL and logging in as the admin user of > postgres, I have created a new user with the CREATEDB privilege. How > does that user log in for the first time to create a DB? Am I required > to create a default user DB when I create the user, or is there a way > to log in with no default DB? The default db is your username, so they can just run "createdb" with no arguments. That will create a db as their unix username. For instance if you create a user named "smarlowee" adn that's their unix username then they can just run createdb and it will create a db named smarlowe for them.
That works like a charm. Thanks Alvaro! On 5/23/13, Alvaro Herrera <alvherre@2ndquadrant.com> wrote: > Melvin Call escribió: >> Hello, >> >> I have a question for which I am unable to find an answer in the >> documentation, if y'all don't mind, I will ask here and hope for an >> answer. >> >> After installing PostgreSQL and logging in as the admin user of >> postgres, I have created a new user with the CREATEDB privilege. How >> does that user log in for the first time to create a DB? Am I required >> to create a default user DB when I create the user, or is there a way >> to log in with no default DB? > > They can use the "postgres" database for this. > > -- > Álvaro Herrera http://www.2ndQuadrant.com/ > PostgreSQL Development, 24x7 Support, Training & Services >
On 5/23/13, Scott Marlowe <scott.marlowe@gmail.com> wrote: > On Thu, May 23, 2013 at 3:01 PM, Melvin Call <melvincall979@gmail.com> > wrote: >> Hello, >> >> I have a question for which I am unable to find an answer in the >> documentation, if y'all don't mind, I will ask here and hope for an >> answer. >> >> After installing PostgreSQL and logging in as the admin user of >> postgres, I have created a new user with the CREATEDB privilege. How >> does that user log in for the first time to create a DB? Am I required >> to create a default user DB when I create the user, or is there a way >> to log in with no default DB? > > The default db is your username, so they can just run "createdb" with > no arguments. That will create a db as their unix username. For > instance if you create a user named "smarlowee" adn that's their unix > username then they can just run createdb and it will create a db named > smarlowe for them. > Thanks Scott. That seems like it would work too, but then I have an unused database laying around, don't I? I realize the resources are minuscule, but I don't like having things on production systems that don't need to be there if I can help it. Out of curiosity, what would be the proper steps if there was no CREATEDB privilege for the role? I'm creating a user that will have all of the create privileges (which prompted my first question), and I expect to create another user that just has just the minimal privileges necessary for that database. Obviously the minimal user will have the admin created DB to connect to, so my question may be moot, eh?
On Thu, May 23, 2013 at 3:38 PM, Melvin Call <melvincall979@gmail.com> wrote: > On 5/23/13, Scott Marlowe <scott.marlowe@gmail.com> wrote: >> On Thu, May 23, 2013 at 3:01 PM, Melvin Call <melvincall979@gmail.com> >> wrote: >>> Hello, >>> >>> I have a question for which I am unable to find an answer in the >>> documentation, if y'all don't mind, I will ask here and hope for an >>> answer. >>> >>> After installing PostgreSQL and logging in as the admin user of >>> postgres, I have created a new user with the CREATEDB privilege. How >>> does that user log in for the first time to create a DB? Am I required >>> to create a default user DB when I create the user, or is there a way >>> to log in with no default DB? >> >> The default db is your username, so they can just run "createdb" with >> no arguments. That will create a db as their unix username. For >> instance if you create a user named "smarlowee" adn that's their unix >> username then they can just run createdb and it will create a db named >> smarlowe for them. >> > Thanks Scott. That seems like it would work too, but then I have an > unused database laying around, don't I? I realize the resources are > minuscule, but I don't like having things on production systems that > don't need to be there if I can help it. > > Out of curiosity, what would be the proper steps if there was no > CREATEDB privilege for the role? I'm creating a user that will have > all of the create privileges (which prompted my first question), and I > expect to create another user that just has just the minimal > privileges necessary for that database. Obviously the minimal user > will have the admin created DB to connect to, so my question may be > moot, eh? Ahh let's say your user is supposed to connect to a database called work all the time. Then he could do this: psql work if you don't want them to have to type that in all the time, then you can add this to .bashrc: export PGDATABASE=work and then psql will just take them straight to work each time without a db argument to it. Hope that helps.