脚本宝典收集整理的这篇文章主要介绍了PostgreSQL安装教程(CentOS),脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
官网安装脚本查询:https://www.postgresql.org/download/linux/redhat/
# 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 postgresql10-server # Optionally initialize the database and enable automatic start: sudo /usr/pgsql-10/bin/postgresql-10-setup initdb sudo systemctl enable postgresql-10 sudo systemctl start postgresql-10
使用postgres用户登录(PostgresSQL安装后会自动创建postgres用户,无密码)
[root@localhost software]# su postgres bash-4.2$
bash-4.2$ psql psql (10.16) 输入 "help" 来获取帮助信息.
create user test_user with password 'abc123'; # 创建用户 create database test_db owner test_user; # 创建数据库 grant all privileges on database test_db to test_user; # 授权
postgres=# q bash-4.2$
修改/var/lib/pgsql/10/data/postgresql.conf文件,取消 listen_addresses 的注释,将参数值改为“*”
bash-4.2$ vim /var/lib/pgsql/10/data/postgresql.conf
修改/var/lib/pgsql/10/data/pg_hba.conf文件,增加下图红框部分内容
bash-4.2$ vim /var/lib/pgsql/10/data/pg_hba.conf
bash-4.2$ su root 密码: [root@localhost software]# systemctl restart postgresql-10.service
修改默认生成的 postgres 用户密码(此postgres非上面的postgres用户,此为数据库的用户,上面的为操作系统的用户)
su - postgrespsql -U postgresalter user postgres with encrypted password '1';
systemctl start postgresql-10.service # 启动服务systemctl stop postgresql-10.service # 关闭服务systemctl restart postgresql-10.service # 重启服务systemctl status postgresql-10.service # 查看状态
以上是脚本宝典为你收集整理的PostgreSQL安装教程(CentOS)全部内容,希望文章能够帮你解决PostgreSQL安装教程(CentOS)所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。