二进制安装postgresql
一、
下载需要的版本文件
网址
wget https://get.enterprisedb.com/postgresql/postgresql-10.11-2-linux-x64-binaries.tar.gz tar -zxvf postgresql-10.11-2-linux-x64-binaries.tar.gz -C /root/pg
二、
新增用户组
useradd postgres passwd postgres
切换用户
su - postgres 初始化目录 /root/pg/pgsql/bin/initdb -D /root/pg/pg_data/ (我这边把初始化的目录放在了root下,初始化的时候会报权限不足的。 所以可以先给root 及 pg一个 755的权限, chmod 755 /root,chmod 755 /root/pg。 注意:千万不要 -R) 三、 开启 /root/pg/pgsql/bin/pg_ctl -D /opt/postgres/pg_data/ -l logfile start (-D 定义存储的数据目录 -l 定义日志) 关闭 /root/pg/pgsql/bin/pg_ctl -D /opt/postgres/pg_data/ stop 四、 环境变量 以上运行postgresql要定义目录,还要加绝对路径,非常麻烦,可以加到环境变量中
su - postgres
vim /root/.bash_profile
PATH=$PATH:$HOME/bin export PATH export PATH export PGHOME=/root/pg/pgsql export PATH=$PATH:$PGHOME/bin export PGDATA=/root/pg/pg_data export PGLOG=/root/pg/pg_log/pg.log
source /root/.bash_profile
chown postgres /root/pg/pg_data
chown postgres /root/pg/pg_log
配置完成后
启动
pg_ctl start
关闭
pg_ctl start
进入客户端
psql
常用命令
\l 或者 \list 展示数据库
切换数据库
\c dbname
\d 展示当前所有表
\q 退出
相关推荐
  WanKaShing    2020-11-12  
   kls00    2020-10-15  
   89921334    2020-07-29  
   83911930    2020-07-28  
   89407707    2020-06-27  
   89921334    2020-06-26  
   89244553    2020-06-21  
   84593973    2020-06-21  
   83911930    2020-06-16  
   yaoding    2020-06-14  
   89244553    2020-06-11  
   89407707    2020-06-11  
   89921334    2020-06-10  
   89407707    2020-06-10  
   goodriver    2020-06-09  
   kevinli    2020-06-06  
   84593973    2020-06-05  
 