本文共 1946 字,大约阅读时间需要 6 分钟。
adduser postgres
pwd
wget https://ftp.postgresql.org/pub/source/v9.6.1/postgresql-9.6.1.tar.gz
tar zxf postgresql-9.6.1.tar.gzcd postgresql-9.6.1./configure --prefix=/usr/local/pgsql9.6.1gmake -j 8gmake install
mkdir -p /data/postgresql5.6/datachown -R postgres.postgres /data/postgresql5.6/datasu - postgres
/usr/local/pgsql9.6/bin/initdb --no-locale -D /data/postgresql5.6/data -E utf8 -U postgres -W
initdb [OPTION] [DATADIR]
-A 或 --auth:指定本地连接的认证方法-D 或 --pgdata:指定数据库簇的原始目录-E 或 --encoding:指定数据库默认编码-W 或 --pwprompt:强制提示密码输入-U 或 --username:指定用户名ls /data/postgresql5.6/data
listen_addresses = '0.0.0.0'port = 10637log_destination = 'csvlog'logging_collector = onlog_directory = '/data/postgresql5.6/log'log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
host all all 127.0.0.1/32 md5host all all 192.168.0.0/24 md5
echo "PGDATA=/data/postgresql5.6/data" >> /etc/profileecho "PGHOST=127.0.0.1" >> /etc/profileecho "PGDATABASE=postgres" >> /etc/profileecho "PGUSER=postgres" >> /etc/profileecho "PGPORT=10637" >> /etc/profileecho "PGPASSWORD=yourpassword" >> /etc/profileecho "PATH=/usr/local/pgsql/bin:$PATH" >> /etc/profileexport PGDATA PGHOST PGDATABASE PGUSER PGPORT PATH PGPASSWORD
source /etc/profile
which psql
echo "/usr/local/pgsql/lib" >> /etc/ld.so.conf.d/pgsql.conf
ldconfig -p | grep libpq
su - postgrespg_ctl start
或者
/usr/local/pgsql9.6/bin/pg_ctl -D /data/postgresql5.6/data start
pg_isready -U postgres
psql -U postgres
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'newpassword';"
pg_ctl restart -D /data/postgresql5.6/data
以上步骤即为PostgreSQL安装与配置的完整流程,确保数据库运行正常并安全运行。
转载地址:http://xpxfk.baihongyu.com/