export PGHOST=127.0.0.1
#默认的数据库名
export PGDATABASE=postgres
#定义日志存放目录
PGLOG="/data/pgdata/serverlog"
source .bash_profile
(7)初始化数据库
#执行数据库初始化脚本
root 用户登录
chown -R postgres.postgres /data/
su - postgres
$/opt/postgresql-10.7/bin/initdb --encoding=utf8 -D /data/pg/data
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.utf8".
initdb: could not find suitable text search configuration for locale
"zh_CN.utf8"
The default text search configuration will be set to "simple".
Data page checksums are disabled.
fixing permissions on existing directory /data/pg/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... 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:
pg_ctl -D /data/pg/data -l logfile start
================
启动数据库
su - postgres
/opt/postgresql-10.3/bin/pg_ctl -D /data/pg/data -l logfile start
(8)相关命令拷贝
root 用户
mkdir /data/pg/bin
cp /opt/postgresql-10.3/bin/* /data/pg/bin
chown -R postgres.postgres /data/pg/bin
---
更改 PGHOME 目录:
原来:
#PostgreSQL 安装目录
export PGHOME=/opt/postgresql-10.7
改成:
/data/pg
启动数据库
su - postgres
评论