PostgreSQL mounted on the detailed steps win7

PostgreSQL installation:
a, the windows installation
installation media: postgresql-9.1.3-1-windows.exe (46M ), the installation process is very simple, as follows:
1, to begin the installation:


2. Select the installation directory:

Note: The installation of PostgreSQL best partition is NTFS format. PostgreSQL primary task is to ensure data integrity, and FAT and FAT32 file system can not provide reliable protection, and FAT file system, the lack of security guarantees, we can not guarantee that the original data is changed in the case of unauthorized. In addition, PostgreSQL used 'pay would stop "function complete the feature table space can not be achieved in the FAT file system.
However, in some systems, only one FAT partition, in this case, you can normally install PostgreSQL, but without initialising the database. After the installation is complete, the FAT partition can be performed manually initdb.exe program, but can not guarantee its safety and reliability, and the establishment of table space will fail.

3. Select the data storage directory:

4, the database superuser and OS user-created passwords

Note: The database superuser is a non-administrator account, which is to reduce defects in PostgreSQL hackers discovered damage to the system, it is necessary to set a password to the database superuser, as shown below, the installation program automatically create service user's The default user name is postgres.

5, set the service listening port, default to 5432

6, select the language run-time environment

注:选择数据库存储区域的运行时语言环境(字符编码格式)。
在选择语言环境时,若选择"default locale"会导致安装不正确;同时,PostgreSQL 不支持 GBK 和 GB18030 作为字符集,如果选择其它四个中文字符集:中文繁体 香港(Chinese[Traditional], Hong Kong S.A.R.)、中文简体 新加坡(Chinese[Simplified], Singapore)、中文繁体 台湾(Chinese[Traditional], Taiwan)和中文繁体 澳门(Chinese[Traditional], Marco S.A.R.),会导致查询结果和排序效果不正确。建议选择"C",即不使用区域。
----我选择了default localt,安装正确;建议选择default localt。

7、安装过程(2分钟)

8、安装完成

安装完成后,从开始文件夹可以看到:

在安装目录可以看到:

其中:data存放数据文件、日志文件、控制文件、配置文件等。
uninstall-postgresql.exe用于卸载已安装的数据库管理系统。
pg_env.bat里配置了数据库的几个环境变量,内容如下:


二、pgAdmin(大象)
对于每种数据库管理系统,都有相当多的设计与管理工具(可视化界面管理工具),有的是数据库厂商自己提供的(一般都至少有一个),有的是第三方公司开发的,你甚至可以自己写一个简单易用的管理工具。例如Oracle的Oracle SQL Developer(自己开发的)、PLSQL Developer(第三方公司开发的)、SQL Server Management Studio(自己开发的)、http://www.oschina.net/project(开源中国)网站上提供的个人或组织开发的简易小巧的管理工具。
PostgreSQL就有好几款流行的管理工具,例如:pgAdmin、navicat_pgsql、phppgsql等。
pgAdmin是一个针对PostgreSQL数据库的设计和管理接口,可以在大多数操作系统上运行。软件用C++编写,具有很优秀的性能。
pgadmin 是与 Postgres 分开发布的,可以从www.pgadmin.org下载。目前装个全功能的PostgreSQL数据库,自带该管理工具。
打开pgAdmin,可以看到在第一部分安装的本地数据库的属性,如下图所示:

图中可以看出,新安装的PostgreSQL数据库管理系统带有一个数据库postgres;已建好两个表空间:pg_default、pg_global。
initdb.exe初始化的两个默认表空间pg_global、pg_default。数据库默认的表空间pg_default 是用来存储系统目录对象、用户表、用户表index、和临时表、临时表index、内部临时表的默认空间,他是模板数据库template0和template1的默认表空间。initdb.exe初始化的两个默认表空间pg_global、pg_default。数据库默认的表空间pg_global是用来存储共享系统目录的默认空间。
pg_default 为 PostgreSQL也可以理解成系统表空间,它对应的物理位置为 $PGDATA/base目录。
在PostgreSQL(pg_catalog)下可以看到postgers数据库的一些数据字典和数据字典视图。

 

新建一个服务器连接,连接远程linux服务器上的PostgreSQL数据库(假设已有远程linux上已安装好PostgreSQL数据库管理系统):

得到数据库属性如下图所示:

图中可以看出,该远程数据库管理系统上建有两个数据库:postgres、cpost;四个表空间:pg_default、pg_global、pis_data、pis_index。

 

三、pgsql
对于每种数据库管理系统,都会提供一个命令行管理接口,例如Oracle的sqlplus,SQL Server的isql和osql等。
凡是用图形管理界面可以实现的功能原则上都可以通过命令行界面命令实现。两者各有优缺点,使用场合不同。在windows下当然常用图形管理界面,因为在图像管理界面中往往都嵌有命令行工具,而在unix和linux下,当然就常用命令行工具了,除了我们在类unix下主要使用字符界面的原因外,还因为大部分情况下我们只能通过telnet或ssh工具远程连接服务器进行操作,此时也只能使用命令行了。
从开始目录打开SQL shell(pgsql),该可执行程序为E:\PostgreSQL\bin\psql.exe。输入密码得到如下图界面:

也可以在修改了系统环境变量Path之后(增加PostgreSQL\bin目录),从命令行直接启动pgsql。

 

至此,PostgreSQL在Windows下安装完毕。

注:postgresql-9.1.14-1-windows-x64.exe下载

Guess you like

Origin www.cnblogs.com/shanghongyun/p/11494058.html