postgresql数据库(9.6)

Install the repository RPM:

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Install PostgreSQL:

sudo yum install -y postgresql96-server

Optionally initialize the database and enable automatic start:

sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb
#设置开机启动
sudo systemctl enable postgresql-9.6
#启动数据库
sudo systemctl start postgresql-9.6
#进入数据库
su - postgres
psql -U postgres
#修改密码
ALTER USER postgres with encrypted password ‘wz123456’;
#配置远程访问:
vim /var/lib/pgsql/9.6/data/postgresql.conf
找到listen_addresses = ‘localhost’ ,将 localhost 改为 *
vmi /var/lib/pgsql/9.6/data/pg_hba.conf
如果允许本地项目访问,将local、IPv4、IPv6的peer改为trust
并在IPv4增加一行:
host    all    all    0.0.0.0/0    md5
#重启数据库
sudo systemctl restart postgresql-9.6
防火墙设置:
firewall-cmd --add-service=postgresql --permanent
firewall-cmd --reload
#查看版本
[root@VM_0_3_centos yum-root-L9XJTV]# psql --version
相关命令
systemctl restart postgresql-9.6.service    #重启服务
systemctl enable postgresql-9.6.service    #设置开机自启
systemctl start postgresql-9.6.service    #开启服务
systemctl status postgresql-9.6.service    #查看服务状态
数据库相关操作:
\q    #退出postgresql
\l    #查看所有数据库
\dt  #查看数据库表
\d test  #查看表结构
\c dbname  #切换数据库
\i /pathA/xxx.sql    #执行某个sql文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值