数据库初始化(需要指定编码) /usr/local/pgsql/bin/initdb -D /home/postgres/data -E UTF-8 —locale=zh_CN.UTF-8 启动数据库 /usr/local/pgsql/bin/pg_ctl -D /home/postgres/data -l /home/postgres/logs/postgres.log start

=========================================================================================================== [root@linux-centos-01 postgres]# su postgres [postgres@linux-centos-01 ~]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data -E UTF-8 —locale=zh_CN.UTF-8 The files belonging to this database system will be owned by user “postgres”. This user must also own the server process.

The database cluster will be initialized with locale “zh_CN.UTF-8”. initdb: could not find suitable text search configuration for locale “zh_CN.UTF-8” The default text search configuration will be set to “simple”.

Data page checksums are disabled.

initdb: directory “/usr/local/pgsql/data” exists but is not empty If you want to create a new database system, either remove or empty the directory “/usr/local/pgsql/data” or run initdb with an argument other than “/usr/local/pgsql/data”. [postgres@linux-centos-01 ~]$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/logs start waiting for server to start…./bin/sh: /usr/local/pgsql/logs: 是一个目录 stopped waiting pg_ctl: could not start server Examine the log output. [postgres@linux-centos-01 ~]$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/logs/postgres.log start waiting for server to start……. done server started [postgres@linux-centos-01 ~]$

================================================================================================================

赋予权限

[root@linux-centos-01 postgres]# chown -R postgres:postgres /home/postgres/data [root@linux-centos-01 postgres]# chmod 700 /home/postgres [root@linux-centos-01 postgres]# clear [root@linux-centos-01 postgres]# su postgres [postgres@linux-centos-01 ~]$ /usr/local/pgsql/bin/initdb -D /home/postgres/data -E UTF-8 —locale=zh_CN.UTF-8 The files belonging to this database system will be owned by user “postgres”. This user must also own the server process.

The database cluster will be initialized with locale “zh_CN.UTF-8”. initdb: could not find suitable text search configuration for locale “zh_CN.UTF-8” The default text search configuration will be set to “simple”.

Data page checksums are disabled.

initdb: directory “/home/postgres/data” exists but is not empty If you want to create a new database system, either remove or empty the directory “/home/postgres/data” or run initdb with an argument other than “/home/postgres/data”. [postgres@linux-centos-01 ~]$ /usr/local/pgsql/bin/pg_ctl -D /home/postgres/data -l /home/postgres/logs/postgres.log start waiting for server to start…./bin/sh: /home/postgres/logs/postgres.log: 权限不够 stopped waiting pg_ctl: could not start server Examine the log output. [postgres@linux-centos-01 ~]$ su root 密码: [root@linux-centos-01 postgres]# chown -R postgres:postgres /home/postgres/logs/postgres.log [root@linux-centos-01 postgres]# chmod 700 /home/postgres/logs/postgres.log [root@linux-centos-01 postgres]# su postgres [postgres@linux-centos-01 ~]$ /usr/local/pgsql/bin/initdb -D /home/postgres/data -E UTF-8 —locale=zh_CN.UTF-8 The files belonging to this database system will be owned by user “postgres”. This user must also own the server process.

The database cluster will be initialized with locale “zh_CN.UTF-8”. initdb: could not find suitable text search configuration for locale “zh_CN.UTF-8” The default text search configuration will be set to “simple”.

Data page checksums are disabled.

initdb: directory “/home/postgres/data” exists but is not empty If you want to create a new database system, either remove or empty the directory “/home/postgres/data” or run initdb with an argument other than “/home/postgres/data”. [postgres@linux-centos-01 ~]$ /usr/local/pgsql/bin/pg_ctl -D /home/postgres/data -l /home/postgres/logs/postgres.log start waiting for server to start…. done server started [postgres@linux-centos-01 ~]$