运行除机器登录用户之外的特定用户的创建/删除DB2数据库命令 [英] Run create/drop DB2 database commands for a specific user other than machine logged-in user

查看:124
本文介绍了运行除机器登录用户之外的特定用户的创建/删除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.


  1. 但是,我需要使用Java代码中的相同机制,但不知道如何。可以打开安装的db2的clp作为不同的用户形式的Java代码?

  2. 是否可以在create / drop命令中关联用户名/密码?


推荐答案

从CLP开始,您可以先使用 ATTACH 您需要的用户ID,然后发出 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         =

在此示例中, 列表数据库目录的输出是 SRV01 ,所以你可以使用: db2 attach srv01 user< username>

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数据库命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆