Welcome 微信登录

首页 / 数据库 / MySQL / Postgresql在Linux下的安装配置与C程序应用

(1)从www.postgresql.org下载pgadmin3-1.6.2.zip 和 postgresql-8.2.3.tar.gz前者是windows下管理端的安装包,后者是数据库的源码安装包。(2)将postgresql-8.2.3.tar.gz拷贝指Linux系统的一个临时目录中,解压缩tar -zxvf postgresql-8.2.3.tar.gz然后进入解压缩后的目录,cd postgresql-8.2.3进行安装配置:#./configure这样配置下来数据库将会安装到默认位置/usr/local/pgsql/下#gmake没有任何问题的话,我们可以看到最后一句提示信息“All of PostgreSQL successfully made. Ready to install.”#gmake install成功安装后能看到最后一句提示信息"PostgreSQL installation complete."cd /usr/local/ls我们能看到pgsql目录,里面有安装好的包(3) 安装后环境设置:用户组添加:#groupadd postgresql#useradd -g postgresql postgresql这时在/home目录下已经生成了postgresql目录,接着进行环境变量和profile的修改#cd /home/postgresql#vi .bash_profile在文件尾添加export PATH=$PATH:/usr/local/pgsql/binexport MANPATH=$MANPATH:/usr/local/pgsql/manexport LD_LIBRARYPATH=$LD_LIBRARYPATH:/usr/local/pgsql/lib然后保存退出。创建数据库目录和日志目录mkdir /usr/local/pgsql/datamkdir /usr/local/pgsql/logtouch /usr/local/pgsql/log/pgsql.log改变属主:chown -R postgresql:postgresql /usr/local/pgsql/datachown -R postgresql:postgresql /usr/local/pgsql/logchown -R postgresql:postgresql /usr/local/pgsql/log/pgsql.log(4):初始化数据库并建立数据库和用户su - postgresqlinitdb -D /usr/local/pgsql/data现在就可以启动数据库了#pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/log/pgsql.log start提示“server starting”然后我们执行进程察看命令查看服务是否已经启动:[postgresql@localhost ~]$ ps -A | grep postgres19932 pts/1 00:00:00 postgres19934 ? 00:00:00 postgres19935 ? 00:00:00 postgres说明数据库服务已经启动。创建数据库[postgresql@localhost ~]$ createdb psmp提示"CREATE DATABASE"创建用户[postgresql@localhost ~]$ createuser -sADEP psmpAdminEnter password for new role:Enter it again:Shall the new role be allowed to create more new roles? (y/n) y提示"CREATE ROLE"其中-s 表示超级用户我们设置密码为psmpPass访问数据库[postgresql@localhost ~]$ psql -d psmp -U psmpAdmin然后就可以运行SQL语句了,比如select或者insert之类(5):接下来在windows上安装pgadmin1.6.2,也就是第一个包解压缩的EXE程序,这个比较简单。当padmin安装完成后,你可能会急着去用这个管理工具连接后台的数据库,可是你一定会遇到连接失败的问题,因为还有一些东西需配置cd /usr/local/pgsql/data/目录下可以看到有2个文件需要修改:pg_hba.conf 和 postgresql.conf修改postgresql.conf 文件中listen_address为"*"并去掉前面的#注视符,对于有些版本的数据库,比如我实用的7.4.16,只需要去掉tcpip_socket = true 和 port = 5432前面的注视符,好了,保存;修改pg_hba.conf文件,在# IPv4-style local connections:host all all 127.0.0.1 255.255.255.255 trust下添加一行host all all 192.168.1.3 255.255.0.0 trust假如你的windows系统的IP为192.168.1.3然后pg_ctl -D /usr/local/pgsql/data reload 重新加载配置这时就可以从pgadmin连接进来了。
  • 1
  • 2
  • 下一页
MySQL的HASH定制安装phpmyadmin时出现“无法载入mysql扩展,请检查PHP配置”的解决方法相关资讯      Linux安装  PostgreSQL 
  • Linux基础教程:Linux的安装与简介  (今 21:00)
  • Linux下RPM包方式安装PostgreSQL  (03月04日)
  • PostgreSQL9.5新特性之行级安全性  (01月19日)
  • Ubuntu 16.04 下安装 PostgreSQL   (08月14日)
  • PostgreSQL 发布全系安全更新  (02月12日)
  • 使用pg_basebackup搭建PostgreSQL  (12/30/2015 09:00:29)
本文评论 查看全部评论 (0)
表情: 姓名: 字数

版权所有©石家庄振强科技有限公司2024 冀ICP备08103738号-5 网站地图