Installation diagram of PostgreSQL in Windows

Source: Internet
Author: User
Tags psql postgresql version

Now, when talking about free databases, most people may first think of MySQL. Indeed, MySQL has been applied in many domestic fields, especially in website setup. However, PostgreSQL is actually the most powerful, rich, and complex free database. Many of its features are the predecessor of many commercial databases such as Oracle and DB2.

As a matter of fact, I recently came into contact with PostgreSQL because of the needs of the project. Recently, PostgreSQL has just released version 8.1. I will talk about my installation experience based on the experience of experts on the Internet, learn from new PostgreSQL users.

Since PostgreSQL 8.0, it has been officially supported by Windows. Before that, if you want to install PostgreSQL on Windows, you must use tools such as Cygwin to simulate the Unix environment, therefore, the stability and performance are lower than those installed on Linux. Let's get started.

Download PostgreSQL for Windows

Log on to http://www.postgresql.org/ftp/and download the latest version. multi-language installation is supported.

Start Installation

After downloading the installation file to your local computer, uncompress the package with the decompression tool, and then, like installing other Windows applications, double-click the postgresql-8.1.msi to start the installation wizard.

The first is to select the language used during the installation process. I have not found the Chinese language while looking for it, so I have to choose to still be able to understand English ^_^. In addition, you can select the following options to write the detailed installation log to the current installation directory for troubleshooting. You can also read the installation process.

Select the installation Language


Click Next to select the installation content options, which are divided into four parts: database server, user interface, database driver, and development module. You can choose to install as needed. To learn more, I have installed all four parts. .

Select installation Option 1

  

Select installation option 2


TIPS: If you prefer to use a graphical interface to manage and operate databases, you can choose to install pgAdminIII on the user interface.

The next step is service configuration. You can run the database server as a Windows system service, which is also a manifestation of Postgresql's true support for Windows installation (for example ).

Select install as a service
 
Set the service name and the Windows account that runs the service. You can enter an existing account or an existing account to allow the installer to automatically create this account. The Account domain item indicates the complete computer name on your computer. You can go to "my computer" --> right-click Properties --> Computer Name, there is a complete computer name in the content (like the cao-393d0fd737d on my machine), copy it, the last point of the name should not be copied, paste it to the Account domain item (note that you can only press Ctrl + V to paste it ).
Automatically create an account

After creating an account, you must configure the database listening port, connection license, and local region and super user settings. Note that Port number indicates the listener Port for configuring PostgreSQL. You can select Chinese and People's Republic of China from the drop-down list to indicate the local region; addresses (connection license) optional or optional; Encoding items in the drop-down list select UTF-8 Encoding (key); Superuser name represents the PostgreSQL user name, you can change, you can also use the default Password (You are advised to change it to your favorite name). Enter the Password required by PostgreSQL (it cannot be blank, it must be more than four characters); Password (again) to confirm your Password, (the super account created here is a database administrator user. Note the difference with the previous service account. Note that this dialog box appears only when PostgreSQL is selected as a system service in the previous step.
Initialize database settings

After you click "Next", a remote connection option will pop up, prompting that the local database connection is acceptable by default. However, if you want the remote computer to connect to the database as well, after installation, set the pg_cmd.conf file separately. The specific settings are described later.

Select the activation process language in the default created Test Database template1. PL/perl requires the installation support of ActiveState Perl 5.8, while PL/python supports Python 2.3, I only chose pgsql here. Note that this dialog box appears only when PostgreSQL is selected to run as a system service and the database component is initialized.
 

Select a process Language


Select the activated modules in the test database template1. All the extension files will be installed. This step only selects which modules will be activated by default in all your databases. These extension modules provide some enhanced functions.
 

Select to load the extension module


OK. Now the installation and configuration parameters are complete. You only need to wait for the next step to complete the installation. The PostgreSQL installation speed is extremely fast and varies slightly according to the time of the machine. The installation successful page is displayed.

Start Installation

  
 

Installation End Interface
After restarting, it is found that PostgreSQL 8.1 program groups are added to the Start Menu program, and several processes are added to the task manager, for example.
Program menu after installation
 

Post-Installation Process
Client connection settings

PostgreSQL rejects connections from all remote clients by default for security reasons. If you want to remotely log on to the server, you need to set pg_assist.conf, choose Start> program> Postgresql 8.1> configuration files to edit pg_cmd.conf.

Edit pg_cmd.conf

Modify to the following content:
# IPv4 local connections:
Host all 127.0.0.1/32 md5
Host all 192.168.9.226/32 md5

This means that the local machine and 192.168.9.226 can connect to the database through an MD5 encrypted password. By modifying the IP address mask, you can also allow the IP address segment to connect to the server. In addition, the authentication method MD5 can also be changed to trust, indicating that the connection to this address is fully trusted (this is more convenient when debugging the program ). Change to password, indicating that the password is connected by the password, but the password is sent in plaintext. After the configuration is complete, you need to restart PostgreSQL to take effect.

Client connection test

After the above installation and setup, a simple PostgreSQL database server has been established. Next we will look at how we can implement the following tasks on this database server: 1. create and delete a database. 2. create or delete a table.

The preceding installation process allows you to access and operate databases in two ways.
Psql to ipvs
From the Start menu --> program --> Postgresql 8.1 --> psql to S, enter the password of the superuser specified during installation, as shown in figure
 

Enter Password


Enter the password and go to the command line interface.
 

Psql operation interface


Enter create database mydb; create a database mydb; drop database mydb to delete the database mydb you do not want;

Use create table myfirsttb (firstcol integer, secondcol text); create a table myfirsttb, and drop table myfirsttb; Delete table myfirsttb.

For more commands, go to the http://www.pgsqldb.org to query related documents.
Use pgAdmin to manage databases
Choose Start> program> Postgresql 8.1> pgAdmin III, as shown in figure

Graphical interface


Right-click PostgreSQL Database Server 8.1 (localhost: 5432) and click connect. Because I set a local connection in pg_hba.conf and use a password, the following dialog box is displayed.

Enter the superuser password window


Enter the superuser password to enter the graphical Management Interface

Graphical Management Interface


You can easily and intuitively manage databases here.
In addition, some other graphical management tools can also be used to manage PostgreSQL databases, such as managing with EMS PostgreSQL Manager (http://www.sqlmanager.net/en.

From the installation process, installing PostgreSQL on Windows is already a very simple task. Just like the author, you can install PostgreSQL in the Wizard, you can install it without administrative permissions. This is a PostgreSQL version that supports Windows (without Cygwin). PostgreSQL is installed as a service and can be started after the machine is restarted.

PostgreSQL has very low minimum resource requirements. For example, if you open the web browser and MS-Word during remote connection, you can see that the test machine is not affected.

If there are deficiencies, since PostgreSQL users are not as widely used as MySQL users, the online discussion forum is not very active and it is an obstacle for beginners to get started. I believe this will gradually improve.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.