安装PostgreSQL数据库(Linux篇)
来源:互联网 发布:mac如何不在桌面显示 编辑:程序博客网 时间:2024/06/04 23:24
http://www.cnblogs.com/marsprj/archive/2013/02/08/2893519.html
0.编译环境
- Linux: CentOS 5.5
- gcc: 4.1.2
1. 安装PostgreSQL
1) 解压postgresql-9.1.7.tar.bz2
#tar jxvf postgresql-9.1.7.tar.bz2
2) 进入解压后的postgresql-9.1.7目录
#cd postgresql-9.1.7
3) 编译postgresql源码
#./configure --prefix=/opt/pgsql-9.1.7
#make
#make install
至此,完成postgresql的安装。进入/opt/pgsql-9.1.7目录可以看到安装后的postgresql的文件。
#ls /opt/pgsql-9.1.7
2.创建postgresql数据库
1) 创建postgres用户
#useradd postgres
修改postgres密码
#passwd postgres
2) 设置postgres用户的环境变量
切换到postgres用户
#su - postgres
进入postgres的主目录
#cd ~
编辑~/.bash_profile文件
#vi ~/.bash_profile
设置以下的环境变量
export PGHOME=/opt/pgsql-9.1.7
export PGDATA=~/data
保存,退出vi。执行以下命令,使环境变量生效
#source ~/.bash_profile
3) 初始化postgres数据库
#initdb
至此,完成postgres数据库的初始化。
4) 启动postgres数据库实例
#pg_ctl start
可以看到postgresql数据库实例已经启动,通过下面的命令可以查看系统中运行的postgres进程
#ps -ef | grep postgres
5) 连接postgresql数据库
#psql -h 127.0.0.1 -d postgres -U postgres
6) 停止postgresql数据库实例
#pg_ctl stop
#ps -ef | grep postgres
可以看到已经没有postgres进程
3. 设置PostgreSQL开机自启动
PostgreSQL的开机自启动脚本位于PostgreSQL源码目录的contrib/start-scripts路径下
linux文件即为linux系统上的启动脚本
1)修改linux文件属性,添加X属性
#chmod a+x linux
2) 复制linux文件到/etc/init.d目录下,更名为postgresql
#cp linux /etc/init.d/postgresql
3)修改/etc/init.d/postgresql文件的两个变量
prefix设置为postgresql的安装路径:/opt/pgsql-9.1.2
PGDATA设置为postgresql的数据目录路径:
4) 执行service postgresql start,就可以启动PostgreSQL服务
#service postgresql start
5)设置postgresql服务开机自启动
#chkconfig --add postgresql
执行上面的命令,就可以实现postgresql服务的开机自启动。
- 安装PostgreSQL数据库(Linux篇)
- 安装PostgreSQL数据库(Linux篇)
- 安装PostgreSQL数据库(Linux篇)
- 安装PostgreSQL数据库(Linux篇)
- 安装PostgreSQL数据库(Linux篇)
- linux安装postgresql数据库
- linux的数据库篇- PostgreSQL安装配置
- linux下安装PostgreSQL数据库
- Linux下安装PostgreSQL数据库
- linux下postgresql数据库的安装
- postgresql安装(linux篇)
- PostgreSQL--安装数据库
- postgresql数据库安装
- postgresql 数据库安装使用
- CentOS安装PostgreSQL数据库
- ubuntu安装数据库postgresql
- PostgreSql数据库安装详解
- 安装PostgreSQL数据库
- JAVA card 应用开发(三) 把APPLET(CAP文件)装载到卡片
- Activity的生命周期、BACK键和HOME键生命周期
- CentOS6.6搭建LNMP环境
- svn回到某个历史版本的做法
- [Leetcode]Triangle
- 安装PostgreSQL数据库(Linux篇)
- UITableView的分割线从最左侧开始, 右箭头,分割线颜色; UITableViewCell中ImageView位置大小控制
- perl 监控主机报警
- glusterfs部分错误解读
- 优化Linux下的内核TCP参数
- Linux学习篇之---linux环境下修改IP
- android 更改popupwindow 的键盘弹出类型
- 几种不同的推荐引擎比较
- 关于centos6.5虚拟机SDL不能显示YUV数据的问题