CentOS7下使用yum安装PostgreSQL9.6
来源:互联网 发布:淘宝爱国者官方旗舰店 编辑:程序博客网 时间:2024/06/05 13:30
CentOS7下使用yum安装PostgreSQL9.6
实验环境
操作系统:CentOS Linux release 7.3.1611 (Core)数据库系统: PostgreSQL 9.6.5IP: 192.168.230.142
创建PostgreSQL9.6的yum源文件
[root@localhost ~]# yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpmLoaded plugins: fastestmirror, langpackspgdg-centos96-9.6-3.noarch.rpm | 4.7 kB 00:00:00 Examining /var/tmp/yum-root-6xDwYA/pgdg-centos96-9.6-3.noarch.rpm: pgdg-centos96-9.6-3.noarchMarking /var/tmp/yum-root-6xDwYA/pgdg-centos96-9.6-3.noarch.rpm to be installedResolving Dependencies--> Running transaction check---> Package pgdg-centos96.noarch 0:9.6-3 will be installed--> Finished Dependency Resolutionbase/7/x86_64 | 3.6 kB 00:00:00 extras/7/x86_64 | 3.4 kB 00:00:00 updates/7/x86_64 | 3.4 kB 00:00:00 Dependencies Resolved=================================================================================================================================== Package Arch Version Repository Size===================================================================================================================================Installing: pgdg-centos96 noarch 9.6-3 /pgdg-centos96-9.6-3.noarch 2.7 kTransaction Summary===================================================================================================================================Install 1 PackageTotal size: 2.7 kInstalled size: 2.7 kIs this ok [y/d/N]: yDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : pgdg-centos96-9.6-3.noarch 1/1 Verifying : pgdg-centos96-9.6-3.noarch 1/1 Installed: pgdg-centos96.noarch 0:9.6-3 Complete!
安装PostgreSQL客户端
[root@localhost ~]# yum install postgresql96Loaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.sohu.com * extras: mirrors.sohu.com * updates: mirrors.sohu.comResolving Dependencies--> Running transaction check---> Package postgresql96.x86_64 0:9.6.5-1PGDG.rhel7 will be installed--> Processing Dependency: postgresql96-libs(x86-64) = 9.6.5-1PGDG.rhel7 for package: postgresql96-9.6.5-1PGDG.rhel7.x86_64--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql96-9.6.5-1PGDG.rhel7.x86_64--> Running transaction check---> Package postgresql96-libs.x86_64 0:9.6.5-1PGDG.rhel7 will be installed--> Finished Dependency ResolutionDependencies Resolved=================================================================================================================================== Package Arch Version Repository Size===================================================================================================================================Installing: postgresql96 x86_64 9.6.5-1PGDG.rhel7 pgdg96 1.4 MInstalling for dependencies: postgresql96-libs x86_64 9.6.5-1PGDG.rhel7 pgdg96 312 kTransaction Summary===================================================================================================================================Install 1 Package (+1 Dependent package)Total download size: 1.7 MInstalled size: 8.1 MIs this ok [y/d/N]: yDownloading packages:(1/2): postgresql96-9.6.5-1PGDG.rhel7.x86_64.rpm | 1.4 MB 00:00:05 (2/2): postgresql96-libs-9.6.5-1PGDG.rhel7.x86_64.rpm | 312 kB 00:00:07 -----------------------------------------------------------------------------------------------------------------------------------Total 215 kB/s | 1.7 MB 00:00:07 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : postgresql96-libs-9.6.5-1PGDG.rhel7.x86_64 1/2 Installing : postgresql96-9.6.5-1PGDG.rhel7.x86_64 2/2 Verifying : postgresql96-9.6.5-1PGDG.rhel7.x86_64 1/2 Verifying : postgresql96-libs-9.6.5-1PGDG.rhel7.x86_64 2/2 Installed: postgresql96.x86_64 0:9.6.5-1PGDG.rhel7 Dependency Installed: postgresql96-libs.x86_64 0:9.6.5-1PGDG.rhel7 Complete!
安装PostgreSQL服务端
[root@localhost ~]# yum install postgresql96-serverLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.sohu.com * extras: mirrors.sohu.com * updates: mirrors.sohu.comResolving Dependencies--> Running transaction check---> Package postgresql96-server.x86_64 0:9.6.5-1PGDG.rhel7 will be installed--> Finished Dependency ResolutionDependencies Resolved=================================================================================================================================== Package Arch Version Repository Size===================================================================================================================================Installing: postgresql96-server x86_64 9.6.5-1PGDG.rhel7 pgdg96 4.3 MTransaction Summary===================================================================================================================================Install 1 PackageTotal download size: 4.3 MInstalled size: 18 MIs this ok [y/d/N]: yDownloading packages:postgresql96-server-9.6.5-1PGDG.rhel7.x86_64.rpm | 4.3 MB 00:00:05 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : postgresql96-server-9.6.5-1PGDG.rhel7.x86_64 1/1 Verifying : postgresql96-server-9.6.5-1PGDG.rhel7.x86_64 1/1 Installed: postgresql96-server.x86_64 0:9.6.5-1PGDG.rhel7 Complete!
安装PostgreSQL拓展包(可选)
[root@localhost ~]# yum install postgresql96-devel.x86_64 Loaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.sohu.com * extras: mirrors.sohu.com * updates: mirrors.sohu.comResolving Dependencies--> Running transaction check---> Package postgresql96-devel.x86_64 0:9.6.5-1PGDG.rhel7 will be installed--> Finished Dependency ResolutionDependencies Resolved=================================================================================================================================== Package Arch Version Repository Size===================================================================================================================================Installing: postgresql96-devel x86_64 9.6.5-1PGDG.rhel7 pgdg96 1.8 MTransaction Summary===================================================================================================================================Install 1 PackageTotal download size: 1.8 MInstalled size: 8.4 MIs this ok [y/d/N]: yDownloading packages:postgresql96-devel-9.6.5-1PGDG.rhel7.x86_64.rpm | 1.8 MB 00:00:25 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : postgresql96-devel-9.6.5-1PGDG.rhel7.x86_64 1/1 Verifying : postgresql96-devel-9.6.5-1PGDG.rhel7.x86_64 1/1 Installed: postgresql96-devel.x86_64 0:9.6.5-1PGDG.rhel7 Complete!
安装PostgreSQL的附加模块(可选)
[root@localhost ~]# yum install postgresql96-contrib.x86_64 Loaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.sohu.com * extras: mirrors.sohu.com * updates: mirrors.sohu.comResolving Dependencies--> Running transaction check---> Package postgresql96-contrib.x86_64 0:9.6.5-1PGDG.rhel7 will be installed--> Finished Dependency ResolutionDependencies Resolved=================================================================================================================================== Package Arch Version Repository Size===================================================================================================================================Installing: postgresql96-contrib x86_64 9.6.5-1PGDG.rhel7 pgdg96 565 kTransaction Summary===================================================================================================================================Install 1 PackageTotal download size: 565 kInstalled size: 2.0 MIs this ok [y/d/N]: yDownloading packages:postgresql96-contrib-9.6.5-1PGDG.rhel7.x86_64.rpm | 565 kB 00:02:58 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : postgresql96-contrib-9.6.5-1PGDG.rhel7.x86_64 1/1 Verifying : postgresql96-contrib-9.6.5-1PGDG.rhel7.x86_64 1/1 Installed: postgresql96-contrib.x86_64 0:9.6.5-1PGDG.rhel7 Complete!
配置PostgreSQL
初始化数据库
[root@localhost ~]# /usr/pgsql-9.6/bin/postgresql96-setup initdbInitializing database ... OK
启动postgresql服务,并设置为开机自动启动
[root@localhost ~]# systemctl enable postgresql-9.6Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.6.service to /usr/lib/systemd/system/postgresql-9.6.service.[root@localhost ~]# systemctl start postgresql-9.6
postgres用户初始配置
安装完成后,操作系统会自动创建一个postgres用户用来管理数据库,为其初始化密码:
[root@localhost ~]# passwd postgres Changing password for user postgres.New password: BAD PASSWORD: The password is shorter than 8 charactersRetype new password: passwd: all authentication tokens updated successfully.
切换至postgres用户,发现提示符设置有问题,编辑之:
[root@localhost ~]# su - postgres-bash-4.2$ vim ./.bash_profile
改为如下配置
[ -f /etc/profile ] && source /etc/profilePGDATA=/var/lib/pgsql/9.6/dataexport PGDATA# If you want to customize your settings,# Use the file below. This is not overridden# by the RPMS.[ -f /var/lib/pgsql/.pgsql_profile ] && source /var/lib/pgsql/.pgsql_profileexport PS1='[\u@\h \W]\$'
使配置生效,看起来清爽多了
-bash-4.2$ source ./.bash_profile [postgres@localhost ~]$
数据库初始配置
使用数据库自带的postgres用户登录数据库,并为其赋予密码
[postgres@localhost ~]$psql -U postgrespsql (9.6.5)Type "help" for help.postgres=# alter user postgres with password 'oracle';ALTER ROLE
如此,PostgreSQL数据库便安装完成了
参考Linux downloads (Red Hat family)
阅读全文
0 0
- CentOS7下使用yum安装PostgreSQL9.6
- centos7下postgresql9.6安装
- CentOS7 PostgreSQL9.6安装
- CentOS7安装PostgreSQL9.6
- CentOS7下安装postgresql9.3+
- CentOS6使用YUM安装Postgresql9.4
- Centos7安装PostgreSQL9.5
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- centos7下使用yum安装mysql
- CentOS7下使用yum安装mysql
- centos7下使用yum安装mysql
- java知识点总结
- 获取设备序列号
- Laravel的核心概念
- source insight研究——正则表达式篇 收藏
- networking restart is deprecated
- CentOS7下使用yum安装PostgreSQL9.6
- SVM之对偶问题
- C#字符串解析相关优化
- android硬件加速
- 关于$.jBox.open从打开的新页面中传值到原来页面
- 线性表
- C++中野指针
- nginx正则表达式
- redis应用场景及实例