Re: super beginner setting up postgresql for the first time

Lists: pgsql-novice
From: Benjamin Golder <benjamin(dot)j(dot)golder(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: super beginner setting up postgresql for the first time
Date: 2010-12-23 17:05:35
Message-ID: AANLkTi=bk51_+VLL=Ro1u4b8qz8ksv_cB9a857RCfTXg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I am so glad there is a novice list, because as a brand new user, I have
plenty of naïve questions.

I am running Mac OSX 10.6.5 on a MacBook Pro. I am trying to learn to use
Postgresql for the very first time in order to use PostGIS and GeoDjango.
for now, I'm just trying to run it on my laptop while I learn the basics.

I recently installed postgresql82 with MacPorts but I can't login to psql,
postgres, or postmaster when I run them from terminal.
They request a password for my username, but will not accept any password
that I know or would have made myself.
I tried using the bash configuration commands listed
here<http://shifteleven.com/articles/2008/03/21/installing-postgresql-on-leopard-using-macports>,
but I still couldn't login.
I then tried to create a new user account with the name postgres but
received an error saying that a user already existed with that name, even
though no user by that name is listed anywhere.
I found a way to delete the account, even though it wasn't liste, and I made
a new account with the name "postgres" that is able to administer the
computer.

I still can't login, because it seems to have associated some password with
my username that I didn't make

I think I've made a mess, and I'm not sure where to fix things. I assume
that I need to learn more about configuring the initial setup. I have read
the online documentation, and done a lot of searching, but I'm still lost. I
assume that I need to have a user account set up in order to use the initdb
command.

So my questions are:
How should I create a user account/password for postgresql and create my
first database to get going? Should I just uninstall and start from scratch?
Is there a configuration file I can edit to reset my password and username?

Thanks and sorry for asking such a terrible question.

Looking forward to learning postgres,

-Ben


From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: Benjamin Golder <benjamin(dot)j(dot)golder(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: super beginner setting up postgresql for the first time
Date: 2010-12-23 17:17:29
Message-ID: AANLkTiki0vV9gy4oRT=bCOXx2n5=R-sGyxoAnDbAWAOd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Thu, Dec 23, 2010 at 9:05 AM, Benjamin Golder
<benjamin(dot)j(dot)golder(at)gmail(dot)com> wrote:
> I am so glad there is a novice list, because as a brand new user, I have
> plenty of naïve questions.

> I then tried to create a new user account with the name postgres but
> received an error saying that a user already existed with that name, even
> though no user by that name is listed anywhere.

The postgres user is created as the default OS user that will own the
PostgreSQL processes and files. Also there is a postgres db user that
is "like" a root/administrator users for the RDBMS.

If your very new to postgresql and you want to learn, the first thing
that you'll need to do is turn off some of the security features until
you learn your way around the system a bit better. Later you'll want
to reapply these features for protection.

First off, you want to make postgres "trust" you. You can to this by
modifying the pg_hba.conf file and then restarting the postgresql
service.

http://www.postgresql.org/docs/9.0/interactive/auth-pg-hba-conf.html

You can test if your permission changes allow you access by using the
psql the command line client application that comes with postgresql.

This will be the first set to get you started.

--
Regards,
Richard Broersma Jr.


From: John DeSoi <desoi(at)pgedit(dot)com>
To: Benjamin Golder <benjamin(dot)j(dot)golder(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: super beginner setting up postgresql for the first time
Date: 2010-12-24 02:41:51
Message-ID: 31FCEC0C-C76C-4C44-83F9-CB62DE6D5863@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


On Dec 23, 2010, at 12:05 PM, Benjamin Golder wrote:

> I recently installed postgresql82 with MacPorts but I can't login to psql, postgres, or postmaster when I run them from terminal.
>

8.2 is really old. If you are just starting you should be using 9.0. Here are a couple of options for Mac installers:

http://www.postgresql.org/download/macosx (Enterprise DB option)

http://www.postgresqlformac.com/lists/downloads/unified_installer_disk_imag/

John DeSoi, Ph.D.


From: Benjamin Golder <benjamin(dot)j(dot)golder(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: super beginner setting up postgresql for the first time
Date: 2010-12-24 07:42:12
Message-ID: AANLkTikNfA1OPkP-PumSd3rV4tnrva=SpB=arM+X6VUX@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Thanks John and Richard for your help.

I've updated (I thought I needed an older version for some dependency, but I
was wrong) to 9.0

In case anyone else happens to find this and has similar questions, here's a
little synopsis of what it took for me to finish setting up postgresql:

delete any existing postgres users.

make a new user from terminal, outlined
here<http://www.postgresql.org/docs/9.0/interactive/postgres-user.html>.
(I added a password and admin group status instead of postgres group status)

Make folders for the new postgres user, just using mkdir in terminal. "
/usr/local/pgsql" and "/usr/local/pgsql/data"

I needed to copy brand new .bash_profile and .bashrc files into the
/usr/local/pgsql directory

then I had to use "su postgres" to login as the postgres account. (not sudo
su postgres)
Then I used source .bash_profile to load the new bash configuration. This is
necessary to ensure that postgres commands are available in the PATH
environment
variable (which I had already set in a different .bash_profile file)

from there I used the
initdb<http://www.postgresql.org/docs/9.0/interactive/app-initdb.html>command
to create a database cluster in
/usr/local/pgsql/data
Then I used the chown command discussed on this
page<http://www.postgresql.org/docs/9.0/interactive/creating-cluster.html>to
give ownership to the postgres user

That finally created the
pg_hba.conf<http://www.postgresql.org/docs/9.0/static/auth-pg-hba-conf.html>file
that Richard mentioned. I did not need to edit this file because the
default authorization value is "trust", meaning that it can be accessed
without a password.

then I could finally run the server, using pg_ctl
start<http://www.postgresql.org/docs/9.0/interactive/server-start.html>

Once the server was running I was able to create new superusers (using
createuser <http://www.postgresql.org/docs/8.1/static/app-createuser.html>, a
Terminal command). While making them, no passwords were requested.

Then I could finally go back into the django
app<http://docs.djangoproject.com/en/dev/intro/tutorial01/>I was
making, edit
the settings.py<http://docs.djangoproject.com/en/dev/ref/settings/#std:setting-DATABASES>file
to include the new superuser, and then run the
syncdb <http://docs.djangoproject.com/en/dev/ref/django-admin/#syncdb>command.
This actually prompted me to make a new superuser with a password,
which I did.

The learning curve is steep on these things! I hope this is helpful to
someone else.

2010/12/23 John DeSoi <desoi(at)pgedit(dot)com>

>
> On Dec 23, 2010, at 12:05 PM, Benjamin Golder wrote:
>
> > I recently installed postgresql82 with MacPorts but I can't login to
> psql, postgres, or postmaster when I run them from terminal.
> >
>
> 8.2 is really old. If you are just starting you should be using 9.0. Here
> are a couple of options for Mac installers:
>
> http://www.postgresql.org/download/macosx (Enterprise DB option)
>
>
> http://www.postgresqlformac.com/lists/downloads/unified_installer_disk_imag/
>
>
> John DeSoi, Ph.D.
>
>
>
>
>