想考PCA认证的,请认真学习以下笔记(学霸笔记,必过过过)
停止数据库执行pg_ctl stop
[postgres@localhost ~]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
删除之前初始化的数据目录
[postgres@localhost ~]$ rm -rf $PGDATA
[postgres@localhost ~]$
重新初始化数据库并指定用户(默认是postgres,端口是5432)
-D参数同样用于指定数据目录
可以指定环境变量PGDATA指向PostgreSQL的目录。
还可以调用pg_ctl命令来初始化数据库集群:
pg_ctl -D /usr/local/pgsql/data initdb
指定的目录必须为空,否则则无法初始化。初始化后整个目录的权限变为700(drwx------)。
[postgres@localhost ~]$ initdb -D $PGDATA -Uteachersun
The files belonging to this database system will be owned by user "postgres".
This user must also