Download the window No Install Version at www.sqlsql.com and decompress it to the hard disk. the following commands are all in the bin directory.
Step 1. initialize the database
Initdb-d directory-e encoding [-u username] -- locale = C
Directory specifies the directory where data files are stored. database files will be created under this directory.
Encoding Character Set
Username administrator user, corresponding to a user in the operating system. This user can manage the database
Note:
Directory cannot be created in advance
After the database is initialized, The Postgres and template1 databases will be automatically created.
Use a non-administrator to run thisProgram
Step2. register the service
Register the window service
Pg_ctl register [-N servicename] [-u username] [-P Password] [-D datadir]
You can use the [-u username] [-P Password] parameters to specify the user who runs the service. For security reasons, you must use a non-administrator user to run the service.
Datadir takes the DIRECTORY parameter in step 1, and grants the user running the service full control permission to the directory.
If you feel uncomfortable, you can log out of the window service.
Pg_ctl unregister [-N servicename]
Step 3: Create a database
Createdb dbname
Step 4. Set the Client Login Mode
Open the pg_cmd.conf file under the data storage directory (that is, the DIRECTORY parameter specified in step 1 ).
At the end of the file, you can add a client that allows connection. Each line is a record, and the last field method is used to specify the login authentication method,
If it is set to trust, it means you can log on without verification.
If it is set to MD5, it means that MD5 is used for password verification. Other types of methods are not currently used
Step 5. You can use the Psql program to log on to the service and enter the SQL command line.
Psql dbname-H hostname_or_host_ip [-P post] [-u username]