linux CentOS6.5安装PostgreSQL9.4.3——傻瓜笔记
2016-05-20 12:32
746 查看
感谢一路走来默默支持和陪伴的你~~~
-----------这是一条华丽的分割线---------------
环境:
系统:CentOS release 6.5 (Final)
数据库软件:postgresql-9.4.3
安装前准备:
1. 准备CentOS6.5系统虚拟机,新增虚拟机网卡为NAT模式,确保虚拟机共享主机网络能够连接internet外网(安装过程中需要借助yum方式下载安装依赖包)。
2. 关闭防火墙:vi /etc/sysconfig/selinux : SELINUX=disabled
安装过程:
1. 下载Postgresql源码包:
# wget http://ftp.postgresql.org/pub/source/v9.4.3/postgresql-9.4.3.tar.bz2
2. 解压源码包并进入:
# tar xjf postgresql-9.4.3.tar.bz2
# cd postgresql-9.4.3
3. 安装依赖包:
# yum -y install gcc*
# yum -y install readline-devel
4. 创建用户及用户密码:postgres/esri1234
# adduser postgres
# passwd postgres
5. 开始编译安装PostgreSQL 数据库。
[root@bogon postgresql-9.4.3]# ./configure --prefix=/home/postgres/pgsql
[root@bogon postgresql-9.4.3]# gmake
[root@bogon postgresql-9.4.3]#
gmake install
6. 设置环境变量:
[root@bogon postgres]# cd /home/postgres/
[root@bogon postgres]# ls
[root@bogon postgres]# vi .bash_profile
把 PATH=$PATH:$HOME/bin
改成 PATH=$PATH:$HOME/bin:/home/postgres/pgsql/bin
保存退出。
让环境变量生效:
[root@bogon postgres]## source .bash_profile
7. 初始化数据库:
新建数据目录:
[root@bogon postgres]# mkdir /home/postgres/pgsql/data
更改权限:
[root@bogon postgres]# chown
postgres:postgres /home/postgres/pgsql/data
切换到postgres用户:
[root@bogon postgres]# su postgres
初始化数据库:
{postgres@bogon~]$ /home/postgres/pgsql/bin/initdb -D /home/postgres/pgsql/data
8. 复制安装目录下的linux文件到/etc/init.d/中,并将linux名称重命名为postgresql(手动也可以)
修改postgresql文件:
[root@bogon postgres-9.4.3]# vi /etc/init.d/postgresql
9. 添加执行权限:
[root@bogon postgres-9.4.3]#
chmod +x /etc/init.d/postgresql
10. 启动数据库:
[root@bogon
postgres-9.4.3]#/etc/init.d/postgresql start
11.设置数据库开机自启动:
[root@bogon postgres]#
chkconfig --add postgresql
[root@bogon
postgres]# chkconfig postgresql on
12. 创建数据库操作历史文件:
[root@bogon
postgres]# touch /home/postgres/pgsql/.pgsql_history
[root@bogon
postgres]# chown postgres:postgres /home/postgres/pgsql/.pgsql_history
13. 测试创建数据库是否成功:
[root@bogon
postgres]# su postgres
{postgres@bogon~]$
createdb test
{postgres@bogon~]$
psql test
14. 测试本地连接:一定要切换到postgres用户上(不能su postgres,在系统上切换)
[postgres@localhost Desktop]$
psql -h 127.0.0.1 -d postgres -U postgres
------------欢迎来访,拒绝转载----------------
参考地址: http://www.linuxidc.com/Linux/2015-07/120565.htm
-----------这是一条华丽的分割线---------------
环境:
系统:CentOS release 6.5 (Final)
数据库软件:postgresql-9.4.3
安装前准备:
1. 准备CentOS6.5系统虚拟机,新增虚拟机网卡为NAT模式,确保虚拟机共享主机网络能够连接internet外网(安装过程中需要借助yum方式下载安装依赖包)。
2. 关闭防火墙:vi /etc/sysconfig/selinux : SELINUX=disabled
安装过程:
1. 下载Postgresql源码包:
# wget http://ftp.postgresql.org/pub/source/v9.4.3/postgresql-9.4.3.tar.bz2
2. 解压源码包并进入:
# tar xjf postgresql-9.4.3.tar.bz2
# cd postgresql-9.4.3
3. 安装依赖包:
# yum -y install gcc*
# yum -y install readline-devel
4. 创建用户及用户密码:postgres/esri1234
# adduser postgres
# passwd postgres
5. 开始编译安装PostgreSQL 数据库。
[root@bogon postgresql-9.4.3]# ./configure --prefix=/home/postgres/pgsql
[root@bogon postgresql-9.4.3]# gmake
[root@bogon postgresql-9.4.3]#
gmake install
6. 设置环境变量:
[root@bogon postgres]# cd /home/postgres/
[root@bogon postgres]# ls
[root@bogon postgres]# vi .bash_profile
把 PATH=$PATH:$HOME/bin
改成 PATH=$PATH:$HOME/bin:/home/postgres/pgsql/bin
保存退出。
让环境变量生效:
[root@bogon postgres]## source .bash_profile
7. 初始化数据库:
新建数据目录:
[root@bogon postgres]# mkdir /home/postgres/pgsql/data
更改权限:
[root@bogon postgres]# chown
postgres:postgres /home/postgres/pgsql/data
切换到postgres用户:
[root@bogon postgres]# su postgres
初始化数据库:
{postgres@bogon~]$ /home/postgres/pgsql/bin/initdb -D /home/postgres/pgsql/data
8. 复制安装目录下的linux文件到/etc/init.d/中,并将linux名称重命名为postgresql(手动也可以)
修改postgresql文件:
[root@bogon postgres-9.4.3]# vi /etc/init.d/postgresql
9. 添加执行权限:
[root@bogon postgres-9.4.3]#
chmod +x /etc/init.d/postgresql
10. 启动数据库:
[root@bogon
postgres-9.4.3]#/etc/init.d/postgresql start
11.设置数据库开机自启动:
[root@bogon postgres]#
chkconfig --add postgresql
[root@bogon
postgres]# chkconfig postgresql on
12. 创建数据库操作历史文件:
[root@bogon
postgres]# touch /home/postgres/pgsql/.pgsql_history
[root@bogon
postgres]# chown postgres:postgres /home/postgres/pgsql/.pgsql_history
13. 测试创建数据库是否成功:
[root@bogon
postgres]# su postgres
{postgres@bogon~]$
createdb test
{postgres@bogon~]$
psql test
14. 测试本地连接:一定要切换到postgres用户上(不能su postgres,在系统上切换)
[postgres@localhost Desktop]$
psql -h 127.0.0.1 -d postgres -U postgres
------------欢迎来访,拒绝转载----------------
参考地址: http://www.linuxidc.com/Linux/2015-07/120565.htm
相关文章推荐
- Linux下解压,压缩JAR包的方法
- linux 终端输出颜色
- linux screen 命令详解
- linux套接字编程之多进程多线程练习
- 操作系统知识(5)--Linux vi/vim
- Linux资源管理之cgroups简介
- windows连接linux_mysql
- Linux下find命令
- LINUX目录结构
- linux 远程 windows 命令:rdesktop vs windows mstsc
- 用户及权限
- linux awk命令详解
- Linux之常用命令
- 2.2#####阿里云软件市场教你搭建网站(linux界面 视频)
- Linux06--Shell程序设计02 数据流重定向与管道
- 小何讲Linux: Linux下进程间通信概述
- 解决克隆 centos虚拟机后修改克隆后的机器的ip、mac、uuid失败的问题
- Linux 平台下 MySQL 5.5 安装 说明 与 示例
- Linux Pthread 总结
- linux进程后台运行及输出重定向