yum 安装Postgresql

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 - postgres
mkdir 9.5/RS01/data -p
mkdir 9.5/RS01/log
pg_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 -Upostgres
2.创建数据库用户ruishi,密码123456
	postgres=# create user ruishi superuser password '123456';
	postgres=# ALTER USER ruishi WITH PASSWORD '123456' ;
1.8 创建RS01项目的表空间
1.创建表空间
	mkdir /home/postgres/pg_tablespaces/rs01_tblspc -p
2.切换到postgres账号
	su postgres
3.使用ruishi用户登录postgres数据库
	psql -Uruishi postgres
4.创建表空间,前提是表空间的目录一定要在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 rs01
create schema ruishi AUTHORIZATION ruishi;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值