• DB2数据库实例创建与删除 学习笔记


    以root身份执行 $DB2HOME/instance/db2idrop -f 实例名,注意一定要加-f,否则不会删除实例下面sqllib文件。如果不幸忘了,执行db2icrt,会报sqllib文件存在的错误,即使先删掉这个文件也不行,执行一下db2icrt,就会生成一部分sqllib,进入死胡同,这个是由于用实例用户登录造成的,也许有个db2profile文件在登录时搞怪,该怎么办呢?看我的吧!用一个非实例的用户登录,su成root,然后再删掉sqllib,试试再db2icrt,问题解决了:)

    创建db2 实例和创建库的方法大致分为两类!一类是图形界面db2setup 创建一种是CLI创建!此处只描述一下CLI方式至于图形界面请大家搜索一下吧!
    db2 创建实例 创建数据库

    1.创建实例用户
    mkdir /db2/db2test 创建实例用户目录
    smitty user
    选择Add a User
    * User NAME                                          [db2test]                                                             
    User ID                                                   []                                                                    
    ADMINISTRATIVE USER?                       false                                                               
    Primary GROUP                                     [db2iadm1]                                                           
    Group SET                                           [staff]                                                              
    ADMINISTRATIVE GROUPS                   []                                                                   
    ROLES                                                         []                                                                   
    Another user can SU TO USER?            true                                                                
    SU GROUPS                                          [ALL]                                                                
    HOME directory                                     [/db2/db2test]
    Initial PROGRAM                                    [/usr/bin/ksh]


    2.创建实例 DB2_install=/usr/opt/db2_08_01/instance
    ./db2icrt -u db2test db2test


    3.创建数据库
    su - db2test
    db2start     #此处不执行启动实例将报:SQL1032N No start database manager command was issued. SQLSTATE=57019
    db2 create db db2test


    4.删除数据库
    db2 drop db db2test
    db2stop


    5.删除实例
    cd DB2_install
    ./db2idrop -f db2test # -f参数一定要添加否则删除完了会报错!


    6.删除用户
    smitty user
    选择Remove a User
    * User NAME                                          [db2test]                                                           +
    Remove AUTHENTICATION information?                  yes      

    删除用户目录
    rm -rf db2test

  • 相关阅读:
    Openwrt智能路由系统开发--内容总结
    EdgeX foundry树莓派搭建与MQTT通讯
    C语言学习截图保存
    使用python生成Latex公式语法
    数据结构与算法之排序
    数据结构与算法之常用数据结构
    MySQL数据库规范 (设计规范+开发规范+操作规范)
    动态规划之LIS(最长上升子序列)
    动态规划之区间DP
    动态规划之状态压缩DP
  • 原文地址:https://www.cnblogs.com/Asatic/p/4894983.html
Copyright © 2020-2023  润新知