zoukankan      html  css  js  c++  java
  • linux安装postgresql 8.3步骤

    下载并解包
    $ tar zxvf postgresql-8.3.4.tar.gz
    $ cd postgresql-8.3.4
    配置

    $./configure --prefix=/usr/local/pgsql --without-readline
    ...
    config.status: linking ./src/makefiles/Makefile.linux to src/Makefile.port

    1、遇到两个错误:
      1)、configure: error: readline library not found
      解决方法:
      安装libtermcap-devel-2.0.8-46.1.i386.rpm
      和readline-devel-5.1-1.1.i386.rpm
      安装过程就不多说了。
      checking for inflate in -lz... no
      2)、configure: error: zlib library not found 
      解决方法:
      安装zlib-devel-1.2.3-3.i386.rpm
      然后./configurate;make;make install
      如果到了这一步就表示安装成功了。
      PostgreSQL installation complete.


    编译
    $ make
    ...
    All of PostgreSQL successfully made. Ready to install.

    测试
    $ make check
    ...
    =======================
    All 103 tests passed. 
    =======================
    安装(root)
    # su -
    # groupadd postgresql
    # useradd -g postgresql postgresql
    # cd <安装目录>
    # make install
    ...
    PostgreSQL installation complete.
    # cd /usr/local
    # ln -s pgsql-8.2.4 pgsql
    # mkdir /usr/local/pgsql/data
    # cd /usr/local/pgsql
    # chown postgresql.postgresql data
    初始化数据库目录(postgresql)
    # su - postgresql
    $ cd /usr/local/pgsql/bin
    设置locale为C,并且template1编码为UNICODE,使数据库支持中文
    $ ./initdb --locale=C -E UNICODE -D ../data/
    ...
    Success. You can now start the database server using:
    ./postgres -D ../data
    or
    ./pg_ctl -D ../data -l logfile start
    配置环境变量及日志文件(root)
    $ (^d)
    # vi /etc/profile
    PATH=/usr/local/pgsql/bin:$PATH
    PGDATA=/usr/local/pgsql/data
    使环境变量生效(或重启操作系统)
    # export PGDATA=/usr/local/pgsql/data
    # touch /var/log/pgsql.log
    # chown postgresql.postgresql /var/log/pgsql.log
    修改配置文件(postgresql)
    $ su - postgresql
    $ cd /usr/local/pgsql/data
    修改配置使监听生效,取消以下两行的注释
    $ vi postgresql.conf
    listen_addresses = '*' # what IP address(es) to listen on; 
    port = 5432 # (change requires restart)

    启动数据库(postgresql)
    $ cd /usr/local/pgsql/bin
    $ ./postmaster -D /usr/local/pgsql/data > /var/log/pgsql.log 2>&1 &
    $ cat /var/log/psql.log
    LOG: checkpoint record is at 0/42C424
    LOG: redo record is at 0/42C424; undo record is at 0/0; shutdown TRUE
    LOG: next transaction ID: 0/593; next OID: 10820
    LOG: next MultiXactId: 1; next MultiXactOffset: 0
    LOG: database system is ready
    创建数据库dm
    $ ./createdb dm
    CREATE DATABASE
    创建用户
    $ ./createuser -A -D -E -P dm
    Enter password for new role: 123456
    Enter it again: 123456
    Shall the new role be allowed to create more new roles? (y/n) y
    CREATE ROLE
    使用psql
    $ ./psql -d dm -U dm
    Welcome to psql 8.2.4, the PostgreSQL interactive terminal.
    Type: \copyright for distribution terms
    \h for help with SQL commands
    \? for help with psql commands
    \g or terminate with semicolon to execute query
    \q to quit

    dm=> \q

    *在psql中若需要使用中文,先发送:
    dm=> set client_encoding to 'gbk';

    配置数据库自启动脚本(root)
    $ (^d)
    # cd /etc/rc.d/init.d
    # cp (安装目录)/postgresql-8.2.4/contrib/start-script/linux postgresql
    # chmod +x postgresql
    # vi postgresql
    prefix=/usr/local/pgsql
    PGDATA="/usr/local/pgsql/data"
    PGUSER=postgresql
    PGLOG="/var/log/pgsql.log"
    # chkconfig --add postgresql
    重启数据库
    # /etc/rc.d/init.d/postgresql restart
    === 配置完成 ===

  • 相关阅读:
    JQuery增加,替换,删除属性应用
    JQuery选择器
    响应式布局
    在 macOS 下备份/还原/重置 LaunchPad 布局
    使用 C# 和 OpenGL (SharpGL) 实现的一个简易画图版
    深入理解计算机系统 (CS:APP)
    深入理解计算机系统 (CS:APP) Lab2
    深入理解计算机系统 (CS:APP) 缓冲区漏洞实验 – Buffer Lab 解析
    ECNU 计算机系统 (CSAPP) 教材习题作业答案集
    计算机网络 Computer Networks​ 期末复习总提纲
  • 原文地址:https://www.cnblogs.com/wangbin/p/1427567.html
Copyright © 2011-2022 走看看