PostgreSQL installation:
1. Installation process under windows
Installation media: postgresql-9.1.3-1-windows.exe (46M), installation process Very simple, the process is as follows:
1. Start the installation:
2. Select the program installation directory:
Note: The partition for installing PostgreSQL is preferably in NTFS format. of. PostgreSQL's first priority is to ensure data integrity, but FAT and FAT32 file systems cannot provide such reliability guarantees, and the FAT file system lacks security guarantees to ensure that the original data is changed without authorization. In addition, the "multi-point" function used by PostgreSQL to complete this feature of the table space cannot be implemented under the FAT file system.
However, in some systems, there is only one FAT partition. In this case, you can install PostgreSQL normally but do not initialize the database. After the installation is completed, you can manually execute the initdb.exe program on the FAT partition, but its security and reliability cannot be guaranteed, and the creation of the table space will also fail.
3. Select the data storage directory:
4. Enter the password of the database super user and the created OS user
Note: The database super user is a non-administrator This is to reduce hackers' use of flaws found in PostgreSQL to cause damage to the system. Therefore, it is necessary to set a password for the database superuser. As shown in the figure below, the user name of the service user automatically created by the installation program defaults to postgres.
5. Set the service listening port, the default is 5432
6. Select the runtime language environment
Note: Select the runtime language environment of the database storage area ( character encoding format).
When selecting the locale, if you select "default locale", the installation will be incorrect; at the same time, PostgreSQL does not support GBK and GB18030 as character sets. If you select the other four Chinese character sets: Chinese Traditional Hong Kong ( Chinese[Traditional], Hong Kong S.A.R.), Chinese[Simplified], Singapore, Chinese[Traditional], Taiwan and Chinese[Traditional], Marco S.A.R., will result in queries Results and sorting effects are incorrect. It is recommended to select "C", which means do not use the area.
----I chose default localt and the installation was correct; it is recommended to choose default localt.
7. Installation process (2 minutes)
8. Installation completed
After the installation is completed, you can see from the start folder:
< p>You can see in the installation directory:Among them: data stores data files, log files, control files, configuration files, etc.
uninstall-postgresql.exe is used to uninstall the installed database management system.
Several environment variables of the database are configured in pg_env.bat, the contents are as follows:
2. pgAdmin (elephant)
For each database management system , there are quite a few design and management tools (visual interface management tools), some are provided by the database vendors themselves (usually there is at least one), some are developed by third-party companies, you can even write a simple and easy-to-use management tool yourself . For example, Oracle's Oracle SQL Developer (self-developed), PLSQL Developer (developed by a third-party company), SQL Server Management Studio (self-developed), and /project (open source China) provide simple and compact tools developed by individuals or organizations. management tools.
PostgreSQL has several popular management tools, such as: pgAdmin, navicat_pgsql, phppgsql, etc.
pgAdmin is a design and management interface for PostgreSQL databases that can run on most operating systems. The software is written in C++ and has excellent performance.
pgadmin is distributed separately from Postgres and can be downloaded from www.pgadmin.org. Currently, a fully functional PostgreSQL database is installed, and the management tool comes with it.
Open pgAdmin, you can see the properties of the local database installed in the first part, as shown in the following figure:
As can be seen in the figure, the newly installed PostgreSQL database management system has A database postgres; two table spaces have been built: pg_default and pg_global.
The two default table spaces pg_global and pg_default initialized by initdb.exe. The database default table space pg_default is the default space used to store system directory objects, user tables, user table index, temporary tables, temporary table index, and internal temporary tables. It is the default table space for template databases template0 and template1. The two default table spaces pg_global and pg_default initialized by initdb.exe. The default table space pg_global of the database is the default space used to store the most shared system directories.
pg_default is PostgreSQL and can also be understood as a system table space, and its corresponding physical location is the $PGDATA/base directory.
You can see some data dictionaries and data dictionary views of the postgers database under PostgreSQL (pg_catalog).
Create a new server connection and connect to the PostgreSQL database on the remote Linux server (assuming that the PostgreSQL database management system has been installed on the remote Linux server):
Get the database properties as shown in the figure below :
As can be seen from the figure, the remote database management system has two databases: postgres and cpost; four table spaces: pg_default, pg_global, pis_data, and pis_index.
3. pgsql
For each database management system, a command line management interface is provided, such as Oracle's sqlplus, SQL Server's isql and osql, etc.
In principle, all functions that can be implemented using the graphical management interface can be implemented through command line interface commands. Both have advantages and disadvantages and are used in different situations. Of course, graphical management interfaces are commonly used under Windows, because command line tools are often embedded in image management interfaces. However, under Unix and Linux, command line tools are of course commonly used, except for the reason why we mainly use character interfaces under Unix-like systems. In addition, because in most cases we can only remotely connect to the server through telnet or ssh tools for operation, at this time we can only use the command line.
Open SQL shell (pgsql) from the start directory. The executable program is E:\PostgreSQL\bin\psql.exe. Enter the password to get the interface as shown below:
You can also start pgsql directly from the command line after modifying the system environment variable Path (adding the PostgreSQL\bin directory).
At this point, PostgreSQL is installed under Windows.