Thursday, August 12. 2010Starting PostgreSQL in windows without installPrinter FriendlyRecommended Books: Windows Command Line Pocket Consultant Windows scripting Learning Guide
Comments
Display comments as
(Linear | Threaded)
A small correction:
%CD% returns the current directory, not the one where the batch file is located (which might be different) You should use %~dp0 instead and put double quotes around all file references in case the binaries are stored e.g in "Program Files": "%~dp0\bin\pg_ctl" -D "%~dp0/data" -l logfile start
Hello. Could you please help me start postgresql without installing it. I have read the post but I didn't understand how to make the batch file. please help me
Sergey,
You copy the contents of that script above into notepad or text editor you choose. Then you save the file with a .bat extension. So something like pgstop_start.bat Copy this file into the folder where you extracted the PostgreSQL windows binaries. Then double-click on the .bat file.
Hi
I'm a bit of a nube when it comes to postgresql. I'm struggling a bit to get the script to run... Here's what i did. Originally i tried following your directions to the letter, so I dowlnoaded the binaries, and I made a bat file and copied the updated script into it and uncommented the necessary line. I ran the script and it complained a bit. It seems that the dp0 thing inserts an extra '/' (eg the script looks for ...//bin...). So I removed the extra slashes and continued. I also created bin and data directories. It still complains that it cant find the path specified for the log file. I was wondering if I'm supposed to create the log file separately and point the script at it somehow? It looks like this is the only part that doesn't work but i would really like a log file. Any assistance would be greatly appreciated.
Hi
I followed your directions exactly and things aren't going according to plan. I'm pretty inexperienced when it comes to batch files and Postgresql so it could be that i'm just being silly... Anyway, I just got the latest binaries (9.0.1-1) and proceeded to follow your instructions. I'm getting errors about certain directories not existing. Is this article relevant to the latest version of Postgresql? If yes, could you please give me some hints about how i might fix my problem? Being a total nube I have a few more questions you might know the answers to... Once I get Postgresql to start sans install, how do I talk to it? If you could explain through means of an example that would be most useful. Could you walk me through the process of defining a database and making a table? Any assistance would be greatly appreciated
Sheena,
Sounds like you might be running into some sort of permission issue. The latest 9.0 binaries should work since that is what we are currently using. The batch script creates the directories (data and log etc) so you shouldn't need to create those. Which Windows OS are you running on and do you have 32-bit or 64-bit. We had tested on both XP and Windows 7. As far as connecting to the database server. The easiest is using pgAdmin3.exe which is in the bin folder. The only caveat we ran into is that first time launch on a virgin computer that has never had pgAdmin installed, you need to register localhost (port), but it doesn't show up right away, so you then have ot close out of PgAdmin and then reopen to see the first registered server. From then on it works fine and you can register other additonal servers as needed.
I have downloaded windows -32 binary files from the following link.
http://www.enterprisedb.com/products/download.do and the file name is : postgresql-9.0.1-1-windows-binaries.zip I have created batch file and tried to execute it but getting error in logfile. the error is : postgres cannot access the server configuration file "C:/Documents and Settings/myself/My Documents/Downloads/postgresql-9.0.1-1-windows-binaries/pgsql/data/postgresql.conf": No such file or directory Please guide me, what to do. Thanks in advance.
Suresh,
I suspect the downloads folder may be protected. Try copying the pgsql folder to the root of your C: drive and then relaunching the bat file from the C:\pgsql folder
Hi
I am using EMS sql manager. But how to register a new database there and how to define a server or what is the name of the server there?
Murat,
I don't have EMS Manager handy in front of me. If you installed the way we described, then the server name will be localhost and the port would be 5439 (note: you can change the port in the batch script if you prefer a different port).
I followed the Post to run the server but when I pressed any key to stop the server, I thrown some error that unable to find director ~dp0 (something like that - unable to reproduce)
now I can see 3 different process postgres.exe which I tried to kill but they come again after that, secondly, how to connect server using pgAdmin3.exe, i tried following way 1. double click on pgadmin3.exe 2. File -> Ad Server.. 3. Fill the fileds Name = "local" host = "localhost" or "127.0.0.1" port = 5439 user = postgres password = [blank] ,none and let other as default but it doesn't do anything no response, not even an error, sometimes it disappears the connection dialogue, but some it doesn't. please help considering me new user of postgressql
Mubashar,
Not sure about your first problem, but as far as second. I consider this a bug and what happens is that PgAdmin doesn't refresh (I think it has to do with as its creating the registry key). So what to do is exit out of pgAdmin3 and come back in and you should see your server. From then on adding more servers will show right away. It's just that very first time.
hi i had follwed the direction actly mention in this page i had created a batch file, problem is that i want to create a database and restored all my tables saved in backup file
when i run the batch file i got the below error please help how would i solve this error Success. You can now start the database server using: "C:\pgsql\\bin\postgres" -D "C:/pgsql/data" or "C:\pgsql\\bin\pg_ctl" -D "C:/pgsql/data" -l logfile start C:\pgsql>"C:\pgsql\\bin\pg_ctl" -D "C:\pgsql\/data" -l logfile start server starting C:\pgsql>cd bin C:\pgsql\bin>psql.exe -d postgres -p 5432 -U postgres < test1.bat psql: FATAL: the database system is starting up
Shilpa
What's this part for? C:\pgsql>cd bin C:\pgsql\bin>psql.exe -d postgres -p 5432 -U postgres < test1.bat psql: FATAL: the database system is starting up You aren't trying to run it in the same batch process are you? You should leave the original batch file that launches "C:\pgsql\\bin\pg_ctl" -D "C:/pgsql/data" -l logfile start running because that is what is keeping the database up. That is why I have a enter key to shut it down. Your restore and everything else should happen in a separate batch process or command window you launch. What is test1.bat? Is that test1.sql you are trying to load? You should use the -f option.
hi Regina, thanks for your reply
but i didnt get your point, see i have download the binaries of postgresql from net then i had created a batch file say name "postgresql" with all the above commands to start server after the server start i have to create a database, test1 is a batch file having a single command to create database ,i had put this both batch files in bin directory of postgresql(which i had downloaded from net) when i double click this postgresql batch file data folder is created and server started but database didnt created below error appear plz help its urgent i had to start postgres in windows without user interface(pgadmin3) from command line and create a database abc to restore all my tables in client machine below code is written in postgresql batch file @ECHO ON @SET PATH="C:\pgsqlnew\bin";%PATH% @SET PGDATA=C:\pgsqlnew\data @SET PGDATABASE=postgres @SET PGUSER=postgres @SET PGPORT=5432 @SET PGLOCALEDIR=C:\pgsqlnew\share\locale "C:\pgsqlnew\bin\initdb" -D C:\pgsqlnew/data "C:\pgsqlnew\bin\pg_ctl" -D "C:\pgsqlnew/data" -l logfile start psql.exe -d postgres -p 5432 -U Admin < test1.bat ECHO "Click enter to stop" pause "C:\pgsqlnew\bin\pg_ctl" -D "C:\pgsqlnew/data" stop and error appear like this C:\pgsqlnew\bin>"C:\pgsqlnew\bin\initdb" -D C:\pgsqlnew/data The files belonging to this database system will be owned by user "Admin". This user must also own the server process. The database cluster will be initialized with locale English_United States.1252. The default database encoding has accordingly been set to WIN1252. The default text search configuration will be set to "english". creating directory C:/pgsqlnew/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 32MB creating configuration files ... ok creating template1 database in C:/pgsqlnew/data/base/1 ... ok initializing pg_authid ... ok initializing dependencies ... ok creating system views ... ok loading system objects' descriptions ... ok creating conversions ... ok creating dictionaries ... ok setting privileges on built-in objects ... ok creating information schema ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to postgres ... ok WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the -A option the next time you run initdb. Success. You can now start the database server using: "C:\pgsqlnew\bin\postgres" -D "C:/pgsqlnew/data" or "C:\pgsqlnew\bin\pg_ctl" -D "C:/pgsqlnew/data" -l logfile start C:\pgsqlnew\bin>"C:\pgsqlnew\bin\pg_ctl" -D "C:\pgsqlnew/data" -l logfile start server starting C:\pgsqlnew\bin>psql.exe -d postgres -p 5432 -U Admin 0ECHO "Click enter to stop" "Click enter to stop" C:\pgsqlnew\bin>pause Press any key to continue . . .
Shilpa,
Yap that all looks right. What I was saying is if you press any key to continue, it will shut down the server. That is by my design. That is because clicking a key will stop the paus and go straight to the stop command. So you have to create your database in a separate batch file (but keep the one that launched the service running).
hi Regina,
i had done that through one batch file just add some option in your script and everything working fine thanks for your greate support this is the modified script for reference @ECHO ON @SET PATH="%~dp0";%PATH% @SET PGDATA=%~dp0\data @SET PGDATABASE=postgres @SET PGUSER=postgres @SET PGPORT=5432 @SET PGLOCALEDIR=%~dp0\share\locale "%~dp0initdb" -U postgres -D %~dp0/data "%~dp0pg_ctl" -w -D "%~dp0/data" -l logfile start psql.exe -d postgres -p 5432 -U postgres < test1.bat psql.exe -d dms -p 5432 -U postgres < temp.backup ECHO "Click enter to stop" pause "%~dp0pg_ctl" -D "%~dp0/data" stop
I cannot connect to the server after it's running using pgadmin3...
It just fails to connect.
I'm trying to use the script on version 8.3.18-1, and I'm getting the following error:
"The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail." Has anyone here had any luck with this versions other than 9? |
Entry's LinksQuicksearchCalendar
Categories
Blog Administration |
Tracked: Aug 13, 17:22
Tracked: Oct 11, 10:28
Tracked: Dec 14, 22:16
Tracked: Jul 19, 17:15