(1)解压后进入:cd
(2)./configure --prefix=“此处设置你的安装路径”,当然,我们也可以直接运行“./configure”,安装到默认位置
(3)make
(4)sudo make install
参考
https://blog.csdn.net/cliviabao/article/details/80097884
https://blog.csdn.net/ghostliming/article/details/53308692
https://cloud.tencent.com/developer/article/1351623
https://www.cnblogs.com/zhaojonjon/p/7682187.html
https://blog.csdn.net/songbaiyao/article/details/72854663
https://blog.csdn.net/sinat_23246437/article/details/54341755
环境及资源
Linux版本:ubuntu16.04
PostgresSQL版本:postgresql-10.3
PostgreSQL官网下载地址:https://www.postgresql.org/ftp/source/v10.3/
下载postgresql-10.3.tar.gz
正文
安装路径为/usr/local/pgsql/
1、解压
gunzip postgresql-10.3.tar.gz
tar xf postgresql-10.3.tar
2、安装
在 /usr/local/pgsql/postgresql-10.3 目录下
执行 ./configure 查看当前环境是否支持安装
发现需要安装依赖
checking for library containing readline... no
configure: error: readline library not found
解决:apt-get install libreadline-dev
checking for inflate in -lz... no
configure: error: zlib library not found
解决:apt-get install zlib1g
apt-get install zlib1g.dev
执行 make
All of PostgreSQL successfully made. Ready to install.
执行 make install 安装postgresql
PostgreSQL installation complete.
执行 adduser postgres 添加postgres 用户
切换到 postgres 用户
执行 mkdir data
chown postgres /usr/local/pgsql/data
执行 /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
3、启动数据库
执行 su - postgres 切换用户
执行 usr/local/pgsql/pg_ctl start -D /usr/local/pgsql/data 启动数据库
附: 重启数据库: usr/local/pgsql/pg_ctl restart -D /usr/local/pgsql/data
关闭数据库: usr/local/pgsql/pg_ctl stop -D /usr/local/pgsql/data
4、创建数据库及用户
执行 ./createdb dbname 创建数据库
执行 ./createuser -P dbuser 创建dbuser用户
5、访问数据库
执行 ./psql
退出 ctrl + d
访问数据库后也可以用sql命令来新建用户
create user dbuser with password 'xxx';
6、远程访问数据库
需设置两个配置文件
1)修改配置文件postgresql.conf
vim /usr/local/pgsql/data/postgresql.conf
修改监听地址:
#listen_addresses='localhost'
#将上面这行改成如下
listen_addresses='*'
listen_address 和 port 默认是被注释的,均要取消注释。
2)修改配置文件/pgsql/data/pg_hba.conf:
vim /usr/local/pgsql/data/pg_hba.conf
添加一条IP授权记录,可以对一个网段授权
# IPv4 myhost connections:
host all all 0.0.0.0/0 trust
修改完成后重启数据库即可
附:我是租用的阿里云服务器,在阿里云服务器上也需要设置一下出入端口(postgresql默认端口为5432)
7、使用windows下图形化工具navicat访问数据库
按照之前添加的用户设置一下就ok啦。
第一次安装 很坎坷,等有时间整理一份新的吧。
/usr/bin/install -c ecpg '/usr/local/pgsql/bin'
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/ecpg/preproc'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/ecpg'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces'
make -C backend/replication/libpqwalreceiver install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/backend/replication/libpqwalreceiver'
make -C ../../../../src/interfaces/libpq all
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
/bin/mkdir -p '/usr/local/pgsql/lib'
/usr/bin/install -c -m 755 libpqwalreceiver.so '/usr/local/pgsql/lib/libpqwalreceiver.so'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/backend/replication/libpqwalreceiver'
make -C backend/replication/pgoutput install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/backend/replication/pgoutput'
/bin/mkdir -p '/usr/local/pgsql/lib'
/usr/bin/install -c -m 755 pgoutput.so '/usr/local/pgsql/lib/pgoutput.so'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/backend/replication/pgoutput'
make -C fe_utils install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
/bin/mkdir -p '/usr/local/pgsql/lib'
/usr/bin/install -c -m 644 libpgfeutils.a '/usr/local/pgsql/lib/libpgfeutils.a'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
make -C bin install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin'
make -C initdb install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/initdb'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c initdb '/usr/local/pgsql/bin/initdb'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/initdb'
make -C pg_archivecleanup install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_archivecleanup'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_archivecleanup '/usr/local/pgsql/bin/pg_archivecleanup'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_archivecleanup'
make -C pg_basebackup install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_basebackup'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_basebackup '/usr/local/pgsql/bin/pg_basebackup'
/usr/bin/install -c pg_receivewal '/usr/local/pgsql/bin/pg_receivewal'
/usr/bin/install -c pg_recvlogical '/usr/local/pgsql/bin/pg_recvlogical'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_basebackup'
make -C pg_config install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_config'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c -m 755 pg_config '/usr/local/pgsql/bin/pg_config'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_config'
make -C pg_controldata install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_controldata'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_controldata '/usr/local/pgsql/bin/pg_controldata'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_controldata'
make -C pg_ctl install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_ctl'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_ctl '/usr/local/pgsql/bin/pg_ctl'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_ctl'
make -C pg_dump install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_dump'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_dump '/usr/local/pgsql/bin'/pg_dump
/usr/bin/install -c pg_restore '/usr/local/pgsql/bin'/pg_restore
/usr/bin/install -c pg_dumpall '/usr/local/pgsql/bin'/pg_dumpall
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_dump'
make -C pg_resetwal install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_resetwal'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_resetwal '/usr/local/pgsql/bin/pg_resetwal'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_resetwal'
make -C pg_rewind install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_rewind'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_rewind '/usr/local/pgsql/bin/pg_rewind'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_rewind'
make -C pg_test_fsync install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_test_fsync'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_test_fsync '/usr/local/pgsql/bin/pg_test_fsync'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_test_fsync'
make -C pg_test_timing install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_test_timing'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_test_timing '/usr/local/pgsql/bin/pg_test_timing'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_test_timing'
make -C pg_upgrade install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_upgrade'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_upgrade '/usr/local/pgsql/bin/pg_upgrade'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_upgrade'
make -C pg_verify_checksums install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_verify_checksums'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_verify_checksums '/usr/local/pgsql/bin/pg_verify_checksums'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_verify_checksums'
make -C pg_waldump install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_waldump'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pg_waldump '/usr/local/pgsql/bin/pg_waldump'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pg_waldump'
make -C pgbench install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pgbench'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c pgbench '/usr/local/pgsql/bin/pgbench'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/pgbench'
make -C psql install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/psql'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
/bin/mkdir -p '/usr/local/pgsql/bin' '/usr/local/pgsql/share'
/usr/bin/install -c psql '/usr/local/pgsql/bin/psql'
/usr/bin/install -c -m 644 ./psqlrc.sample '/usr/local/pgsql/share/psqlrc.sample'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/psql'
make -C scripts install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/bin/scripts'
make -C ../../../src/interfaces/libpq all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/port all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../src/fe_utils all
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
make[4]: Nothing to be done for 'all'.
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/fe_utils'
/bin/mkdir -p '/usr/local/pgsql/bin'
/usr/bin/install -c createdb '/usr/local/pgsql/bin'/createdb
/usr/bin/install -c dropdb '/usr/local/pgsql/bin'/dropdb
/usr/bin/install -c createuser '/usr/local/pgsql/bin'/createuser
/usr/bin/install -c dropuser '/usr/local/pgsql/bin'/dropuser
/usr/bin/install -c clusterdb '/usr/local/pgsql/bin'/clusterdb
/usr/bin/install -c vacuumdb '/usr/local/pgsql/bin'/vacuumdb
/usr/bin/install -c reindexdb '/usr/local/pgsql/bin'/reindexdb
/usr/bin/install -c pg_isready '/usr/local/pgsql/bin'/pg_isready
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin/scripts'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/bin'
make -C pl install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/pl'
make -C plpgsql install
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/pl/plpgsql'
make -C src install
make[4]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/pl/plpgsql/src'
/bin/mkdir -p '/usr/local/pgsql/lib'
/usr/bin/install -c -m 755 plpgsql.so '/usr/local/pgsql/lib/plpgsql.so'
/bin/mkdir -p '/usr/local/pgsql/share/extension'
/bin/mkdir -p '/usr/local/pgsql/include/server'
/usr/bin/install -c -m 644 ./plpgsql.control ./plpgsql--1.0.sql ./plpgsql--unpackaged--1.0.sql '/usr/local/pgsql/share/extension/'
/usr/bin/install -c -m 644 './plpgsql.h' '/usr/local/pgsql/include/server'
make[4]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/pl/plpgsql/src'
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/pl/plpgsql'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/pl'
make -C makefiles install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/makefiles'
/bin/mkdir -p '/usr/local/pgsql/lib/pgxs/src/makefiles'
/usr/bin/install -c -m 644 ./pgxs.mk '/usr/local/pgsql/lib/pgxs/src/makefiles/'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/makefiles'
make -C test/regress install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/test/regress'
make -C ../../../src/port all
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make -C ../../../contrib/spi
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/contrib/spi'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/contrib/spi'
/bin/mkdir -p '/usr/local/pgsql/lib/pgxs/src/test/regress'
/usr/bin/install -c pg_regress '/usr/local/pgsql/lib/pgxs/src/test/regress/pg_regress'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/test/regress'
make -C test/isolation install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/test/isolation'
make -C ../../../src/interfaces/libpq all
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/interfaces/libpq'
make -C ../../../src/port all
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/port'
make -C ../../../src/common all
make[3]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/common'
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/test/isolation'
make -C test/perl install
make[2]: Entering directory '/home/zhu/Desktop/postgresql-11.2/src/test/perl'
make[2]: Nothing to be done for 'install'.
make[2]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src/test/perl'
/bin/mkdir -p '/usr/local/pgsql/lib/pgxs/src'
/usr/bin/install -c -m 644 Makefile.global '/usr/local/pgsql/lib/pgxs/src/Makefile.global'
/usr/bin/install -c -m 644 Makefile.port '/usr/local/pgsql/lib/pgxs/src/Makefile.port'
/usr/bin/install -c -m 644 ./Makefile.shlib '/usr/local/pgsql/lib/pgxs/src/Makefile.shlib'
/usr/bin/install -c -m 644 ./nls-global.mk '/usr/local/pgsql/lib/pgxs/src/nls-global.mk'
make[1]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/src'
make -C config install
make[1]: Entering directory '/home/zhu/Desktop/postgresql-11.2/config'
/bin/mkdir -p '/usr/local/pgsql/lib/pgxs/config'
/usr/bin/install -c -m 755 ./install-sh '/usr/local/pgsql/lib/pgxs/config/install-sh'
/usr/bin/install -c -m 755 ./missing '/usr/local/pgsql/lib/pgxs/config/missing'
make[1]: Leaving directory '/home/zhu/Desktop/postgresql-11.2/config'
PostgreSQL installation complete.
zhu@emg-pc:~/Desktop/postgresql-11.2$ sudo mkdir data
zhu@emg-pc:~/Desktop/postgresql-11.2$ ls
aclocal.m4 config.log configure contrib data GNUmakefile HISTORY Makefile src
config config.status configure.in COPYRIGHT doc GNUmakefile.in INSTALL README
zhu@emg-pc:~/Desktop/postgresql-11.2$ sudo chown postgres /usr/local/pgsql/data
chown: invalid user: ‘postgres’
zhu@emg-pc:~/Desktop/postgresql-11.2$ sudo /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
zhu@emg-pc:~/Desktop/postgresql-11.2$ sudo /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&q &
[1] 27346
bash: q: ambiguous redirect
zhu@emg-pc:~/Desktop/postgresql-11.2$ su -postgres
su: invalid option -- 'o'
Usage: su [options] [LOGIN]
Options:
-c, --command COMMAND pass COMMAND to the invoked shell
-h, --help display this help message and exit
-, -l, --login make the shell a login shell
-m, -p,
--preserve-environment do not reset environment variables, and
keep the same shell
-s, --shell SHELL use SHELL instead of the default in passwd
[1]+ Exit 1 sudo /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data > logfile 2>&q
zhu@emg-pc:~/Desktop/postgresql-11.2$ su - postgres
No passwd entry for user 'postgres'
zhu@emg-pc:~/Desktop/postgresql-11.2$ su - postgres
No passwd entry for user 'postgres'
zhu@emg-pc:~/Desktop/postgresql-11.2$ usr/local/pgsql/pg_ctl start -D /usr/local/pgsql/data
bash: usr/local/pgsql/pg_ctl: No such file or directory
zhu@emg-pc:~/Desktop/postgresql-11.2$ sudo usr/local/pgsql/pg_ctl start -D /usr/local/pgsql/data
sudo: usr/local/pgsql/pg_ctl: command not found
zhu@emg-pc:~/Desktop/postgresql-11.2$ ls /usr/local/pgsql/data
ls: cannot access '/usr/local/pgsql/data': No such file or directory
zhu@emg-pc:~/Desktop/postgresql-11.2$ ls data
zhu@emg-pc:~/Desktop/postgresql-11.2$ ladata
ladata: command not found
zhu@emg-pc:~/Desktop/postgresql-11.2$ ls data
zhu@emg-pc:~/Desktop/postgresql-11.2$ ls /usr/local
bin etc games include lib man pgsql sbin share src
zhu@emg-pc:~/Desktop/postgresql-11.2$ ls /usr/local/pgsql
bin include lib share
zhu@emg-pc:~/Desktop/postgresql-11.2$ sudo adduser postgres
Adding user `postgres' ...
Adding new group `postgres' (1004) ...
Adding new user `postgres' (1004) with group `postgres' ...
Creating home directory `/home/postgres' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for postgres
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
zhu@emg-pc:~/Desktop/postgresql-11.2$ ls data
zhu@emg-pc:~/Desktop/postgresql-11.2$ chown postgres /usr/local/pgsql/data
chown: cannot access '/usr/local/pgsql/data': No such file or directory
zhu@emg-pc:~/Desktop/postgresql-11.2$ mkdir data chown postgres /usr/local/pgsql/data
mkdir: cannot create directory ‘data’: File exists
mkdir: cannot create directory ‘/usr/local/pgsql/data’: Permission denied
zhu@emg-pc:~/Desktop/postgresql-11.2$ sudo mkdir data chown postgres /usr/local/pgsql/data
mkdir: cannot create directory ‘data’: File exists
mkdir: cannot create directory ‘chown’: File exists
mkdir: cannot create directory ‘postgres’: File exists
zhu@emg-pc:~/Desktop/postgresql-11.2$ sudo /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/postgres -D /usr /local/pgsql/data > logfile 2>&1 &
[1] 27465
zhu@emg-pc:~/Desktop/postgresql-11.2$ su - postgres
Password:
postgres@emg-pc:~$ sudo usr/local/pgsql/pg_ctl start -D /usr/local/pgsql/data
[sudo] password for postgres:
postgres is not in the sudoers file. This incident will be reported.
postgres@emg-pc:~$ usr/local/pgsql/pg_ctl start -D /usr/local/pgsql/data
-su: usr/local/pgsql/pg_ctl: No such file or directory
postgres@emg-pc:~$ ls usr/local/pg_ctl
ls: cannot access 'usr/local/pg_ctl': No such file or directory
postgres@emg-pc:~$ /usr
-su: /usr: Is a directory
postgres@emg-pc:~$ ls usr/local/pgsql
ls: cannot access 'usr/local/pgsql': No such file or directory
postgres@emg-pc:~$ ls
examples.desktop
postgres@emg-pc:~$ ls usr
ls: cannot access 'usr': No such file or directory
postgres@emg-pc:~$ ls
examples.desktop
postgres@emg-pc:~$ ls
examples.desktop
postgres@emg-pc:~$ ls examples.desktop
examples.desktop
postgres@emg-pc:~$ ls /usr
bin games include lib libx86_64-linux-gnu local locale sbin share src
postgres@emg-pc:~$ /usr/local/pgsql/pg_ctl start -D /usr/local/pgsql/data
-su: /usr/local/pgsql/pg_ctl: No such file or directory
postgres@emg-pc:~$ ls /usr/local/pgsql/pg_ctl
ls: cannot access '/usr/local/pgsql/pg_ctl': No such file or directory
postgres@emg-pc:~$ ls /usr/local/pgsql
bin data include lib share
postgres@emg-pc:~$ su zhu
Password:
zhu@emg-pc:/home/postgres$ ls /usr/local/pgsql/data
zhu@emg-pc:/home/postgres$ sudo /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
zhu@emg-pc:/home/postgres$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "zhu".
This user must also own the server process.
The database cluster will be initialized with locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: zh_CN.UTF-8
NUMERIC: zh_CN.UTF-8
TIME: zh_CN.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/pgsql/data ... initdb: could not change permissions of directory "/usr/local/pgsql/data": Operation not permitted
zhu@emg-pc:/home/postgres$ sudo /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
zhu@emg-pc:/home/postgres$ su -postgres
su: invalid option -- 'o'
Usage: su [options] [LOGIN]
Options:
-c, --command COMMAND pass COMMAND to the invoked shell
-h, --help display this help message and exit
-, -l, --login make the shell a login shell
-m, -p,
--preserve-environment do not reset environment variables, and
keep the same shell
-s, --shell SHELL use SHELL instead of the default in passwd
zhu@emg-pc:/home/postgres$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "zhu".
This user must also own the server process.
The database cluster will be initialized with locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: zh_CN.UTF-8
NUMERIC: zh_CN.UTF-8
TIME: zh_CN.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/pgsql/data ... initdb: could not change permissions of directory "/usr/local/pgsql/data": Operation not permitted
zhu@emg-pc:/home/postgres$ mkdir -p /data/postgresql/{data,log}
mkdir: cannot create directory ‘/data’: Permission denied
mkdir: cannot create directory ‘/data’: Permission denied
zhu@emg-pc:/home/postgres$ sudo mkdir -p /data/postgresql/{data,log}
zhu@emg-pc:/home/postgres$ sudo clown -R postgres.postgres /data/postgresql/
sudo: clown: command not found
zhu@emg-pc:/home/postgres$ clown -R postgres.postgres /data/postgresql/
No command 'clown' found, did you mean:
Command 'cdown' from package 'cdtool' (universe)
Command 'chown' from package 'coreutils' (main)
clown: command not found
zhu@emg-pc:/home/postgres$ chown -R postgres.postgres /data/postgresql/
chown: changing ownership of '/data/postgresql/data': Operation not permitted
chown: changing ownership of '/data/postgresql/log': Operation not permitted
chown: changing ownership of '/data/postgresql/': Operation not permitted
zhu@emg-pc:/home/postgres$ su postgres
Password:
postgres@emg-pc:~$ cd /usr/local/pgsql/bin
postgres@emg-pc:/usr/local/pgsql/bin$ ./initb -E utf8 -D /data/postgresql/data
bash: ./initb: No such file or directory
postgres@emg-pc:/usr/local/pgsql/bin$ ./initdb -E utf8 -D /data/postgresql/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 locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: zh_CN.UTF-8
NUMERIC: zh_CN.UTF-8
TIME: zh_CN.UTF-8
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /data/postgresql/data ... initdb: could not change permissions of directory "/data/postgresql/data": Operation not permitted
postgres@emg-pc:/usr/local/pgsql/bin$ sudo ./initdb -E utf8 -D /data/postgresql/data
[sudo] password for postgres:
Sorry, try again.
[sudo] password for postgres:
postgres is not in the sudoers file. This incident will be reported.
postgres@emg-pc:/usr/local/pgsql/bin$ sudo ./initdb -E utf8 -D /data/postgresql/data
[sudo] password for postgres:
postgres is not in the sudoers file. This incident will be reported.
postgres@emg-pc:/usr/local/pgsql/bin$ ./initdb -E utf8 -D /data/postgresql/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 locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: zh_CN.UTF-8
NUMERIC: zh_CN.UTF-8
TIME: zh_CN.UTF-8
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /data/postgresql/data ... initdb: could not change permissions of directory "/data/postgresql/data": Operation not permitted
postgres@emg-pc:/usr/local/pgsql/bin$ ls /data/postgresql/data
postgres@emg-pc:/usr/local/pgsql/bin$ chown -
chown: missing operand after ‘-’
Try 'chown --help' for more information.
postgres@emg-pc:/usr/local/pgsql/bin$ chown /data/postgresql/data
chown: missing operand after ‘/data/postgresql/data’
Try 'chown --help' for more information.
postgres@emg-pc:/usr/local/pgsql/bin$ chown /data/postgresql/data/
chown: missing operand after ‘/data/postgresql/data/’
Try 'chown --help' for more information.
postgres@emg-pc:/usr/local/pgsql/bin$ su zhu
Password:
zhu@emg-pc:/usr/local/pgsql/bin$ ls data
ls: cannot access 'data': No such file or directory
zhu@emg-pc:/usr/local/pgsql/bin$ ls data
ls: cannot access 'data': No such file or directory
zhu@emg-pc:/usr/local/pgsql/bin$ ls /data/
postgresql
zhu@emg-pc:/usr/local/pgsql/bin$ chown -R /data/postgresql/data/
chown: missing operand after ‘/data/postgresql/data/’
Try 'chown --help' for more information.
zhu@emg-pc:/usr/local/pgsql/bin$ sudo chown -R /data/postgresql/data/
chown: missing operand after ‘/data/postgresql/data/’
Try 'chown --help' for more information.
zhu@emg-pc:/usr/local/pgsql/bin$ su postgres
Password:
postgres@emg-pc:/usr/local/pgsql/bin$ createdb sammy
The program 'createdb' is currently not installed. To run 'createdb' please ask your administrator to install the package 'postgresql-client-common'
postgres@emg-pc:/usr/local/pgsql/bin$ su zhu
Password:
zhu@emg-pc:/usr/local/pgsql/bin$ sudo -u postgres createdb sammy
sudo: createdb: command not found
zhu@emg-pc:/usr/local/pgsql/bin$ su postgres
Password:
postgres@emg-pc:/usr/local/pgsql/bin$ sudo createdb sammy
[sudo] password for postgres:
postgres is not in the sudoers file. This incident will be reported.
postgres@emg-pc:/usr/local/pgsql/bin$ createdb sammy
The program 'createdb' is currently not installed. To run 'createdb' please ask your administrator to install the package 'postgresql-client-common'
postgres@emg-pc:/usr/local/pgsql/bin$ cls
No command 'cls' found, but there are 18 similar ones
cls: command not found
postgres@emg-pc:/usr/local/pgsql/bin$ clear
postgres@emg-pc:/usr/local/pgsql/bin$ su zhu
Password:
zhu@emg-pc:/usr/local/pgsql/bin$ sudo -u postgres -i
postgres@emg-pc:~$ 123456
123456: command not found
postgres@emg-pc:~$ ls
examples.desktop
postgres@emg-pc:~$ createdb -E -UTF8 -0 osm gis
The program 'createdb' is currently not installed. To run 'createdb' please ask your administrator to install the package 'postgresql-client-common'
postgres@emg-pc:~$ su zhu
Password:
zhu@emg-pc:/home/postgres$ chown postgres /usr/local/pgsql/data
chown: changing ownership of '/usr/local/pgsql/data': Operation not permitted
zhu@emg-pc:/home/postgres$ sudo chown postgres /usr/local/pgsql/data
zhu@emg-pc:/home/postgres$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "zhu".
This user must also own the server process.
The database cluster will be initialized with locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: zh_CN.UTF-8
NUMERIC: zh_CN.UTF-8
TIME: zh_CN.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/pgsql/data ... initdb: could not change permissions of directory "/usr/local/pgsql/data": Operation not permitted
zhu@emg-pc:/home/postgres$ sudo /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
zhu@emg-pc:/home/postgres$ cls
No command 'cls' found, but there are 18 similar ones
cls: command not found
zhu@emg-pc:/home/postgres$ clear
zhu@emg-pc:/home/postgres$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
The files belonging to this database system will be owned by user "zhu".
This user must also own the server process.
The database cluster will be initialized with locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: zh_CN.UTF-8
NUMERIC: zh_CN.UTF-8
TIME: zh_CN.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/pgsql/data ... initdb: could not change permissions of directory "/usr/local/pgsql/data": Operation not permitted
zhu@emg-pc:/home/postgres$ chown postgres /usr/pg/postgresql-9.6.1/ -R
chown: cannot access '/usr/pg/postgresql-9.6.1/': No such file or directory
zhu@emg-pc:/home/postgres$ su - postgres
Password:
postgres@emg-pc:~$ ^C
postgres@emg-pc:~$ sr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
-su: sr/local/pgsql/bin/initdb: No such file or directory
postgres@emg-pc:~$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/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 locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: zh_CN.UTF-8
NUMERIC: zh_CN.UTF-8
TIME: zh_CN.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /usr/local/pgsql/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:
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
postgres@emg-pc:~$ /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
[1] 28021
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data
pg_ctl: no operation specified
Try "pg_ctl --help" for more information.
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
postgres@emg-pc:~$ usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start
-su: usr/local/pgsql/bin/pg_ctl: No such file or directory
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data start
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....2019-03-28 17:42:26.498 CST [28064] FATAL: lock file "postmaster.pid" already exists
2019-03-28 17:42:26.498 CST [28064] HINT: Is another postmaster (PID 28021) running in data directory "/usr/local/pgsql/data"?
stopped waiting
pg_ctl: could not start server
Examine the log output.
postgres@emg-pc:~$ /usr/local/pgsql/bin/initdb test
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 locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: zh_CN.UTF-8
NUMERIC: zh_CN.UTF-8
TIME: zh_CN.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
creating directory test ... 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:
/usr/local/pgsql/bin/pg_ctl -D test -l logfile start
postgres@emg-pc:~$ cd...
cd...: command not found
postgres@emg-pc:~$ ls /usr/local/pgsql/
bin data include lib share
postgres@emg-pc:~$ /usr/local/pgsql/bin/psql/ test
-su: /usr/local/pgsql/bin/psql/: Not a directory
postgres@emg-pc:~$ /usr/local/pgsql/bin/pgsql/ test
-su: /usr/local/pgsql/bin/pgsql/: No such file or directory
postgres@emg-pc:~$ ls /usr/local/pgsql/bin
clusterdb ecpg pg_config pg_isready pg_rewind pg_waldump vacuumdb
createdb initdb pg_controldata pg_receivewal pg_test_fsync postgres
createuser pg_archivecleanup pg_ctl pg_recvlogical pg_test_timing postmaster
dropdb pg_basebackup pg_dump pg_resetwal pg_upgrade psql
dropuser pgbench pg_dumpall pg_restore pg_verify_checksums reindexdb
postgres@emg-pc:~$ ls /usr/local/pgsql/bin/psql
/usr/local/pgsql/bin/psql
postgres@emg-pc:~$ ls /usr/local/pgsql/bin test
test:
base pg_hba.conf pg_notify pg_stat pg_twophase postgresql.auto.conf
global pg_ident.conf pg_replslot pg_stat_tmp PG_VERSION postgresql.conf
pg_commit_ts pg_logical pg_serial pg_subtrans pg_wal
pg_dynshmem pg_multixact pg_snapshots pg_tblspc pg_xact
/usr/local/pgsql/bin:
clusterdb ecpg pg_config pg_isready pg_rewind pg_waldump vacuumdb
createdb initdb pg_controldata pg_receivewal pg_test_fsync postgres
createuser pg_archivecleanup pg_ctl pg_recvlogical pg_test_timing postmaster
dropdb pg_basebackup pg_dump pg_resetwal pg_upgrade psql
dropuser pgbench pg_dumpall pg_restore pg_verify_checksums reindexdb
postgres@emg-pc:~$ ls /usr/local/pgsql/bin/psql test
/usr/local/pgsql/bin/psql
test:
base pg_hba.conf pg_notify pg_stat pg_twophase postgresql.auto.conf
global pg_ident.conf pg_replslot pg_stat_tmp PG_VERSION postgresql.conf
pg_commit_ts pg_logical pg_serial pg_subtrans pg_wal
pg_dynshmem pg_multixact pg_snapshots pg_tblspc pg_xact
postgres@emg-pc:~$ usr/local/pgsql/pg_ctl start -D /usr/local/pgsql/data
-su: usr/local/pgsql/pg_ctl: No such file or directory
postgres@emg-pc:~$ usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data
-su: usr/local/pgsql/bin/pg_ctl: No such file or directory
postgres@emg-pc:~$ usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
-su: usr/local/pgsql/bin/pg_ctl: No such file or directory
postgres@emg-pc:~$ ls /usr/local/pgsql/bin/pg_ctl
/usr/local/pgsql/bin/pg_ctl
postgres@emg-pc:~$ ls /usr/local/pgsql/data/
base pg_hba.conf pg_notify pg_stat pg_twophase postgresql.auto.conf
global pg_ident.conf pg_replslot pg_stat_tmp PG_VERSION postgresql.conf
pg_commit_ts pg_logical pg_serial pg_subtrans pg_wal postmaster.opts
pg_dynshmem pg_multixact pg_snapshots pg_tblspc pg_xact postmaster.pid
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....2019-03-28 17:54:53.512 CST [28223] FATAL: lock file "postmaster.pid" already exists
2019-03-28 17:54:53.512 CST [28223] HINT: Is another postmaster (PID 28021) running in data directory "/usr/local/pgsql/data"?
stopped waiting
pg_ctl: could not start server
Examine the log output.
postgres@emg-pc:~$ \conninfo
conninfo: command not found
postgres@emg-pc:~$ conninfo
conninfo: command not found
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data/
waiting for server to shut down.... done
server stopped
[1]+ Done /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data > logfile 2>&1
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
waiting for server to start....2019-03-28 17:58:43.863 CST [28263] LOG: listening on IPv4 address "127.0.0.1", port 5432
2019-03-28 17:58:43.913 CST [28263] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2019-03-28 17:58:44.031 CST [28264] LOG: database system was shut down at 2019-03-28 17:58:30 CST
2019-03-28 17:58:44.074 CST [28263] LOG: database system is ready to accept connections
done
server started
postgres@emg-pc:~$ ./psql
-su: ./psql: No such file or directory
postgres@emg-pc:~$ vim /usr/local/pgsql/data/postgresql.conf
postgres@emg-pc:~$ vim /usr/local/pgsql/data/postgresql.conf
postgres@emg-pc:~$
postgres@emg-pc:~$
postgres@emg-pc:~$ ll /usr/local/pgsql/data/
total 128
drwx------ 19 postgres root 4096 3月 28 18:11 ./
drwxr-xr-x 7 root root 4096 3月 28 16:59 ../
drwx------ 5 postgres postgres 4096 3月 28 17:38 base/
drwx------ 2 postgres postgres 4096 3月 28 17:38 global/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_commit_ts/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_dynshmem/
-rw------- 1 postgres postgres 4513 3月 28 17:38 pg_hba.conf
-rw------- 1 postgres postgres 1636 3月 28 17:38 pg_ident.conf
drwx------ 4 postgres postgres 4096 3月 28 18:03 pg_logical/
drwx------ 4 postgres postgres 4096 3月 28 17:38 pg_multixact/
drwx------ 2 postgres postgres 4096 3月 28 17:58 pg_notify/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_replslot/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_serial/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_snapshots/
drwx------ 2 postgres postgres 4096 3月 28 17:58 pg_stat/
drwx------ 2 postgres postgres 4096 3月 28 18:10 pg_stat_tmp/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_subtrans/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_tblspc/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_twophase/
-rw------- 1 postgres postgres 3 3月 28 17:38 PG_VERSION
drwx------ 3 postgres postgres 4096 3月 28 17:38 pg_wal/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_xact/
-rw------- 1 postgres postgres 88 3月 28 17:38 postgresql.auto.conf
-rw------- 1 postgres postgres 23852 3月 28 17:38 postgresql.conf
-rw------- 1 postgres postgres 59 3月 28 17:58 postmaster.opts
-rw------- 1 postgres postgres 88 3月 28 17:58 postmaster.pid
postgres@emg-pc:~$ ll -a /usr/local/pgsql/data/
total 128
drwx------ 19 postgres root 4096 3月 28 18:11 ./
drwxr-xr-x 7 root root 4096 3月 28 16:59 ../
drwx------ 5 postgres postgres 4096 3月 28 17:38 base/
drwx------ 2 postgres postgres 4096 3月 28 17:38 global/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_commit_ts/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_dynshmem/
-rw------- 1 postgres postgres 4513 3月 28 17:38 pg_hba.conf
-rw------- 1 postgres postgres 1636 3月 28 17:38 pg_ident.conf
drwx------ 4 postgres postgres 4096 3月 28 18:03 pg_logical/
drwx------ 4 postgres postgres 4096 3月 28 17:38 pg_multixact/
drwx------ 2 postgres postgres 4096 3月 28 17:58 pg_notify/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_replslot/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_serial/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_snapshots/
drwx------ 2 postgres postgres 4096 3月 28 17:58 pg_stat/
drwx------ 2 postgres postgres 4096 3月 28 18:10 pg_stat_tmp/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_subtrans/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_tblspc/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_twophase/
-rw------- 1 postgres postgres 3 3月 28 17:38 PG_VERSION
drwx------ 3 postgres postgres 4096 3月 28 17:38 pg_wal/
drwx------ 2 postgres postgres 4096 3月 28 17:38 pg_xact/
-rw------- 1 postgres postgres 88 3月 28 17:38 postgresql.auto.conf
-rw------- 1 postgres postgres 23852 3月 28 17:38 postgresql.conf
-rw------- 1 postgres postgres 59 3月 28 17:58 postmaster.opts
-rw------- 1 postgres postgres 88 3月 28 17:58 postmaster.pid
postgres@emg-pc:~$ vim /usr/local/pgsql/data/postgresql.conf
postgres@emg-pc:~$ vim /usr/local/pgsql/data/postgresql.conf
postgres@emg-pc:~$ vim /pgsql/data/pg_hba.conf
postgres@emg-pc:~$ vim /pgsql/data/pg_hba.conf
postgres@emg-pc:~$
postgres@emg-pc:~$
postgres@emg-pc:~$ ls
examples.desktop logfile test
postgres@emg-pc:~$
postgres@emg-pc:~$
postgres@emg-pc:~$
postgres@emg-pc:~$
postgres@emg-pc:~$ ls /
bin data home lib media osrm-routed.log run srv usr vmlinuz.old
boot dev initrd.img lib64 mnt proc sbin sys var
cdrom etc initrd.img.old lost+found opt root snap tmp vmlinuz
postgres@emg-pc:~$ vim /usr/local/pgsql/data/pg_hba.conf
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....2019-03-28 18:18:08.436 CST [28514] FATAL: lock file "postmaster.pid" already exists
2019-03-28 18:18:08.436 CST [28514] HINT: Is another postmaster (PID 28263) running in data directory "/usr/local/pgsql/data"?
stopped waiting
pg_ctl: could not start server
Examine the log output.
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data/
waiting for server to shut down....2019-03-28 18:18:23.521 CST [28263] LOG: received fast shutdown request
2019-03-28 18:18:23.548 CST [28263] LOG: aborting any active transactions
2019-03-28 18:18:23.549 CST [28263] LOG: background worker "logical replication launcher" (PID 28270) exited with exit code 1
2019-03-28 18:18:23.549 CST [28265] LOG: shutting down
2019-03-28 18:18:23.720 CST [28263] LOG: database system is shut down
done
server stopped
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
waiting for server to start....2019-03-28 18:18:31.992 CST [28524] LOG: listening on IPv4 address "0.0.0.0", port 5432
2019-03-28 18:18:31.992 CST [28524] LOG: listening on IPv6 address "::", port 5432
2019-03-28 18:18:32.067 CST [28524] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2019-03-28 18:18:32.210 CST [28525] LOG: database system was shut down at 2019-03-28 18:18:23 CST
2019-03-28 18:18:32.261 CST [28524] LOG: database system is ready to accept connections
done
server started
postgres@emg-pc:~$
开启关闭数据库
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/
postgres@emg-pc:~$ /usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data/