Run create/drop DB2 database commands for a specific user other than machine logged-in user(为机器登录用户以外的特定用户运行创建/删除 DB2 数据库命令)
问题描述
db2 CREATE DATABASE XYZ
db2 DROP DATABASE XYZ
这些 db2 命令不支持在 db2cmd/db2clp 上为机器登录用户以外的特定用户执行时指定用户名/密码.因此导致异常
These db2 commands which doesn't provide support to specify username/password while executing on db2cmd/db2clp for a specific user other than machine logged-in user. Hence result a exception
SQL1092N 请求的命令或操作失败,因为用户标识没有执行请求的命令或操作的权限."
"SQL1092N The requested command or operation failed because the user ID does not have the authority to perform the requested command or operation."
当通过选择以不同用户身份运行"来运行相同的命令时,它可以正常工作.
And when the same commands run as by choosing 'Run as different user', it works properly.
- 但我需要使用 Java 代码中的相同机制,但不知道如何使用.是否可以以不同的用户表单 Java 代码打开已安装的 db2 的 clp??
- 是否可以在创建/删除命令中关联用户名/密码?
推荐答案
在 CLP 中,您可以首先使用所需的任何用户 ID ATTACH
到实例,然后发出 CREATE DATABASE
命令.
From the CLP you can first ATTACH
to the instance using whatever user ID you need, and then issue the CREATE DATABASE
command.
如果实例在您的本地机器上运行,您只需像这样附加:
If the instance is running on your local machine, you just attach like this:
$ db2 attach to db2inst1 user db2inst1
Enter current password for db2inst1:
Instance Attachment Information
Instance server = DB2/LINUXX8664 9.7.5
Authorization ID = DB2INST1
Local instance alias = DB2INST1
如果实例在远程服务器上运行,则附加到您在数据库目录中定义的节点名称":
If the instance is running on a remote server, you attach to the "node name" that you have defined in your database catalog:
$ db2 list db directory
System Database Directory
Number of entries in the directory = 1
Database 1 entry:
Database alias = SAMPLE
Database name = SAMPLE
Node name = SRV01
Database release level = d.00
Comment =
Directory entry type = Remote
Catalog database partition number = -1
Alternate server hostname =
Alternate server port number =
在本例中,list database directory
的输出中显示的节点名称为 SRV01
,因此您可以使用以下命令进行附加:db2 attach to srv01 user <用户名>
.
In this example, the Node Name shown in the output from list database directory
is SRV01
, so you would attach using: db2 attach to srv01 user <username>
.
这篇关于为机器登录用户以外的特定用户运行创建/删除 DB2 数据库命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为机器登录用户以外的特定用户运行创建/删除 DB2 数据库命令
基础教程推荐
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01