centos7安装PostgreSQL


1.PostgresSQL安装

1.安装rpm文件
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2.安装客服端
yum install postgressql10
3.安装服务端
yum install postgresql10-server
4.初始化
/usr/pgsql-10/bin/postgresql-10-setup initdb
5.设置自动启动并且启动postgressql服务
systemctl enable postgresql-10
systemctl start postgresql-10

2.创建用户和数据库

1.使用postgres用户登录(PostgresSQL安装后会自动创建postgres用户,无密码)
su - postgres
2.登录到postgresql数据库
psql
3.创建用户
create user test with password 'cps123';
4.创建数据库
create database test_db owner test ;
5.授权访问
grant all privileges on database test_db to test

3.远程访问

1、修改/var/lib/pgsql/10/data/postgresql.conf文件,取消 listen_addresses 的注释,将参数值改为“*”
2、修改/var/lib/pgsql/10/data/pg_hba.conf文件,添加
host all all 0.0.0.0/0 md5
3、切换到root用户,重启postgresql服务
systemctl restart postgresql-10.service


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM