Page 1 of 2

How to install initdb manually on Win XP

PostPosted: Fri Jul 18, 2008 4:17 am
by vesper
disclaimer: This is a rough guide about installing initdb manually for those having problems with the Postgres installer. I really wouldn't recommend following the advice in this post unless you've tried EVERYTHING else. I'm not a computer professional and I can't guarantee this will work for you so try this very carefully and at your own risk. This guide gets messy, and I'm recalling from memory so it might have some inaccuracies here and there... Obviously I'm not responsible if you break your computer.

I have Win XP and was running into the "failed to run initdb:1" error, despite having my admin/privileges setup supposedly correct. After trying nearly everything and having no luck finding a process that was blocking the install, I decided to find a way to run initdb manually and get around the installer's "failed to run initdb:1" error. Here's what I did:

The easy part
fresh complete uninstall/re-install PT3 w/ PostgreSQL
Run PostgreSQL installer
UNCHECK the box that prompts you to install the database as a service (this will install the program and service but won't run initdb in the install)
continue with the install of postgreSQL

Running initdb manually
start->run-> cmd
in the command prompt type: cd "c:\program files\postgresql\8.3\bin" (include the quotations)
the directory should be changed now, type in: initdb -W -A md5 -D c:/data
(roughly this means you're going to make the postgre user and create the "data" folder in c:\ instead of the usual postgresql install path.)
If your problem is the same as mine you'll have to bypass passwords later, but remember it just in case.

there should now be a folder called "data" in C:\, you should verify it's there.
drag and drop the "data" folder that you created into C:\program files\postgresql\8.3\
Restart your computer
start->all programs->postgresql->start database
open up pokertracker 3
type in the password...it probably won't work yet and come up with more errors.

Unable to connect to this database errors
Now you're probably getting an "unable to connect to this database" error. If this is the case, you need to look at what the database log says:

If it says ident authentication failed for user "postgres", you have to remove password requirements:
To remove password requirements go to start -> postgresql -> configuration files -> pg_hba.cfg and scroll to the bottom of this file. In the two places you see md5, replace them w/the word trust, then save the file. Local queries to the database will no longer be password validated.

Now try it. That solves it for most people, but you might a "role "postgres" does not exist" error next, as I did. The solution for this is to create the postgres user:
start -> postgresql -> command prompt
type in "createuser postgres"

Now the password requirement is overridden and the postgres user exists.
OK hopefully now it's ready to go. I actually hope no one needs to use this guide, use it as a last resort. The main problem is that you'll have to run the database every time you want to use PT. If anyone knows a workaround to that, please let me know.

Oh and thanks to keggler who was very kind to wade through emails and procmon logs trying to help me out.

Re: How to install initdb manually on Win XP

PostPosted: Fri Jul 18, 2008 4:26 am
by WhiteRider
Thanks for writing this, I've added a link to it in the Database / Postgres FAQ.

Re: How to install initdb manually on Win XP

PostPosted: Fri Jul 18, 2008 5:40 am
by keggler
well done vesper for sticking with it...

i have to think that by creating the folders in the c:\ root it has to be the original permissions on the c:\program files folder that were messed up...

it's got to be a permission or registry key this high up, because by walloping postgres and it's folders and the user prior to a fresh install would have erased the permissions - maybe it's a rogue registry key somewhere that's left after the uninstall??


susan

Re: How to install initdb manually on Win XP

PostPosted: Thu Dec 11, 2008 7:13 pm
by pomop
Excellent. Thanks. Solved my problem.

Just a little thing though:

It's "createuser postgres" and not "create user postgres"

Once again, thanks for this guide :)

Re: How to install initdb manually on Win XP

PostPosted: Tue Jan 06, 2009 1:39 am
by Peter Rhodan
that didnt work for me - same result - it removes the db at the end - what the hell is all the 'd:\myplay.pif' is not a recognisable command stuff??? There are lines of it

apart from the endless d:\myplay.pif lines it all seems to be ok till here:

creating configeration files ... ok
creating template1 database in c:/data/base/1 ... 'd:\myplay.pif' is not recognized as an internal or external command, operable program or batch file
child process excited with exit code 1
initdb: removing data directory "c:/data"

Re: How to install initdb manually on Win XP

PostPosted: Tue Jan 06, 2009 10:27 am
by kraada
I'm not sure what's causing that error message; it is quite odd. I'd recommend taking a look at the official uninstall/reinstall PostgreSQL guide and working through that and seeing if you get stuck anywhere.

If you do, let me know where in the document you're having problems and we'll go from there.

Re: How to install initdb manually on Win XP

PostPosted: Wed Jan 28, 2009 7:23 pm
by thedean88
when i try to create user it doesn't let me what am i supposed to type exactly?

Re: How to install initdb manually on Win XP

PostPosted: Thu Jan 29, 2009 10:38 am
by kraada
It should be just:
CREATE USER postgres;


what error message is it giving you?

Re: How to install initdb manually on Win XP

PostPosted: Sat Jan 31, 2009 3:13 am
by thedean88
it is saying " 'create' is not recognized as an internal or external command operable program or batch file."

Re: How to install initdb manually on Win XP

PostPosted: Sat Jan 31, 2009 10:20 am
by kraada
I just looked back at the OP and he has one slight mistake (I'll edit it shortly).

The Windows program to create a user is called createuser not create user.

CREATE USER is a PostgreSQL command, usable at a PostgreSQL command prompt; createuser is a windows program runnable from the Windows command prompt.

The short answer is: createuser followed by your username will work.