一旦 PostgreSQL 安装在您的 Linux 服务器上,在启动 PostgreSQL 服务器之前,创建数据库安装非常重要。要创建数据库安装,请使用以下命令
[root@deep] /# su postgres
[postgres@deep /]$ initdb --pglib=/usr/lib/pgsql --pgdata=/var/lib/pgsql
|
我们正在使用用户名 postgres 初始化数据库系统uid=40。 该用户将拥有所有文件,并且还必须拥有服务器进程。
Creating Postgres database system directory /var/lib/pgsql/base
Creating template database in /var/lib/pgsql/base/template1
Creating global classes in /var/lib/pgsql/base
Adding template1 database to pg_database...
Vacuuming template1
Creating public pg_user view
Creating view pg_rules
Creating view pg_views
Creating view pg_tables
Creating view pg_indexes
Loading pg_description
|
[postgres@deep /]$ chmod 640 /var/lib/pgsql/pg_pwd
[postgres@deep /]$ exit
|
命令
--pglib将指定 PostgreSQL 的库目录在系统中的位置,命令
--pgdata将指定数据库文件在此 Linux 安装中必须驻留的位置。
: 不要以root!身份创建数据库安装。这将是一个重大的安全漏洞。
请不要忘记稍后清理
[root@deep] /# cd /var/tmp
[root@deep ]/tmp# rm -rf postgresql-version/ postgresql-version.tar.gz
|
删除 egcs-c++-version.i386.rpm 包以节省空间。
[root@deep] /# rpm -e egcs-c++
|