小工具知识网

当前位置: 首页 > 行业知识 > yum 安装Postgresql

行业知识

yum 安装Postgresql

2026-12-03 17:51:17 来源:互联网转载
1.1 安装postgre yum源
yum install -y https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-3.noarch.rpm
1.2 yum安装postgre
yum install postgresql95-server postgresql95-contrib postgresql95-devel.x86_64 postgresql95-python.x86_64 -y
1.3 将postgres最新版本的bin路径添加到~/.bash_profile
su – postgres

在.bash_profile中添加export PATH=$PATH:/usr/pgsql-9.5/bin

()
Source .bash_profile
1.4需要将/etc/skel的文件复制到/home目录下
cp -a /etc/skel/. /home/postgres/
1.5 初始化数据库目录
su - postgresmkdir 9.5/RS01/data -pmkdir 9.5/RS01/logpg_ctl -D 9.5/RS01/data/ initdb
1.6 启动数据库
pg_ctl -D 9.5/RS01/data/ -l 9.5/RS01/log/postgresql.log start
1.7 使用原始用户postgres进行登录
1.使用postgres用户登录psql -Upostgres2.创建数据库用户ruishi,密码123456postgres=# create user ruishi superuser password '123456';postgres=# ALTER USER ruishi WITH PASSWORD '123456' ;
1.8 创建RS01项目的表空间
1.创建表空间mkdir /home/postgres/pg_tablespaces/rs01_tblspc -p2.切换到postgres账号su postgres3.使用ruishi用户登录postgres数据库psql -Uruishi postgres4.创建表空间,前提是表空间的目录一定要在linux里面创建好CREATE TABLESPACE rs01_tblspc LOCATION '/home/postgres/pg_tablespaces/rs01_tblspc';
1.9 创建RS01数据库并指定对应的表空间
CREATE DATABASE rs01 OWNER ruishi TABLESPACE rs01_tblspc;
1.10 创建ruishi Schema,并更改Schema关联到用户ruishi
psql -Uruishi rs01create schema ruishi AUTHORIZATION ruishi;
()

上一篇:服务器怎么改背景?

下一篇:windows怎么添加服务器?