#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Posts
    149
    Rep Power
    14

    Postgres Setup Question


    I'm in the process of installing Postgres 7.3.3 onto my Slackware system, but have some questions that I can't seem to find answers for in the manual.

    I've been able to successfully compile the database and install it to get the server to run. I ran
    initdb -D /usr/local/pgsql/data without errors. So from what I understand, the only account that I can log into the database with now is 'postgres', correct? Now, should the initdb script created an initial database for the postgres root user? Reason I ask is because I try to connect to the database as the postgres user:

    [postgres /usr/local/pgsql/bin]$ ./psql

    ... and get this error:

    psql: FATAL: Database 'postgres' does not exist in the system catalog.

    I *can* create other databases using 'createdb' from the command-line and successfully log into those databases and do transactions... but I'm left wondering why a 'default' database for the user wasn't created... or does this even happen? Do I have to do it? Furthermore, can I assume that adding other user accounts to the database would have similar results?

    Just looking for some clarification on this.

    Thanks,

    - coredumped.

    ---| Edited 06/29/2003 |---------------------
    I *think* I have solved the problem by running the 'createdb' script without any arguments. It seems to create a database for the 'current' user. Now, however, I hav another problem, but I'll post that to a new thread.

    - coredumped.
    Last edited by coredumped; June 29th, 2003 at 06:43 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    #devshed @ irc2.beyondirc.net
    Posts
    231
    Rep Power
    12
    When you first install PostgreSQL, you need to login using the database "template1". Every other database created is modeled after that template database. Once your in you can create new databases, users, et cetera.
    .
  4. #3
  5. Me likey breadsticks...
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2003
    Location
    Los Angeles
    Posts
    1,189
    Rep Power
    18
    Yup, dotcomguy is right, if you just wanna check if everything's working, as postgres do psql -d template1 and you should be able to connect fine.

    If you'd like to add new users check the createuser script.

    HTH
    -b
    PostgreSQL, it's what's for dinner...
  6. #4
  7. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    Yes, 'psql' usually assumes two things, if you just run it without parameters:

    1. You are logging into PostgreSQL as the same user you are running your command linefrom.
    2. You are logging into a database with the same name as the user. This doesn't mean that a default database for the user was created.

    So, in coredumped's case, it assumed user postgres, and a database named postgres, which didn't exist.

    If you just want a different database, you don't even need the -d switch. 'psql your_db_name' is good enough.
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com

IMN logo majestic logo threadwatch logo seochat tools logo