db2 list db directory
db2 connect to SAMPLE
db2 "select substr(bpname,1,12) as bpname from syscat.bufferpools"
# 输入进入命令
db2
# 进入后
db2 => connect to testdb
更多见: Tutorial: Using the Db2 command line processor
db2: command not found
/SQL10007N Message "-1390" could not be retreived. Reason code: "3".
If you have access to the instance owning id, login and issue:
echo $INSTHOME
On the server, try this:
cat /etc/passwd |grep db2inst1
Look at the instance owner’s .profile
, .bash_profile
, and .bashrc
to find the lines automatically added by Db2 on installation
Once you have the correct location, you can substitute it in to the lines above in the .profile, .bash_profile, and/or the .bashrc of every user who wants to execute Db2 commands:
if [ -f /db2home/db2inst1/sqllib/db2profile ]; then
. /db2home/db2inst1/sqllib/db2profile
fi
直接用命令: source /db2home/db2inst1/sqllib/db2profile
使用下列程序: db2cmd.exe
db2cmdadmin.exe
Powershell: set-item -path env:DB2CLP -value "**$$**"
本人今天使用 update
更新 dbm cfg 时候出现了 SQL5001N 错误, 那么就简单的分析一下并给出解决方法:
操作命令: db2 update dbm cfg using DFT_MON_STMT on
报错信息: SQL5001N "KEVIN" does not have the authority to change the database manager configuration file.
kevin
是我的 db2 数据库用户名字, 明显是 kevin
用户没有被授权修改 dbm 配置
首先介绍一下最基础的东西:
实例级权限:
Unix/Linux 下的查看命令:
db2 get dbm cfg|grep "SYSADM"
db2 get dbm cfg|grep "SYSCTRL"
db2 get dbm cfg|grep "SYSMAINT"
db2 get dbm cfg|grep "SYSMON"
知道了上面的知识, 那么就知道修改 dbm cfg 需要有最高权限 sysadm
,
那么在我的终端是用 db2 get dbm cfg | grep SYSADM
SYSADM group name (SYSADM_GROUP) = DB2IADM1
知道只有在组 DB2IADM1
下才有权限去执行, 那么我的示例用户是 db2inst1
,
那么终端使用命令 id db2inst1
uid=801(db2inst1) gid=901(db2iadm1) 组=901(db2iadm1),903(db2dadm1)
很明显使用 db2inst1
用户就可以执行 dbm cfg 更新了
然后使用 su
命令切换到 db2inst1
用户下: su - db2inst1
最后再次使用命令: db2 update dbm cfg using DFT_MON_STMT on
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully.
IBM site
https://hub.docker.com/r/ibmcom/db2
db2inst1
testdb
IBM Db2