5、初始化pgdata
[pumpkin@hl231 ~]$ mkdir ~/pgdata – 创建目录
[pumpkin@hl231 ~]$ initdb -D ~/pgdata/ --encoding=UTF8 --locale=C -- 初始化一个数据库实例
The files belonging to this database system will be owned by user "pumpkin".
This user must also own the server process.
The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /home/pumpkin/pgdata ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /home/pumpkin/pgdata/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
初始化完毕之后修改几个参数:
Postgresql.conf 中 修改
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5434 # (change requires restart)
pg_hba.conf 中按照自己的要求进行修改,本次只是用来进行演示,所以我就不改了。
6、启动数据库
[pumpkin@hl231 ~]$ pg_ctl start -D ~/pgdata/ -- 启动数据库
server starting
$[pumpkin@hl231 ~]$ psql -U postgres
psql (9.3.5)
Type "help" for help.
postgres=# select version();
version
--------------------------------------------------------------------------------
------------------------------
PostgreSQL 9.3.5 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7 20120
313 (Red Hat 4.4.7-4), 64-bit
(1 row)