2

In IBM Data Studio, I can create a connection to a remote IBM DB2 LUW database named DBEMP and browse the schema and data.

Here is the steps to create the database connection:

  1. From IBM Data Studio, In Database Adminstration Explorer, select: New -> New Connection to Database.
  2. Select DB2 for Linux, UNIX, and Windows in the dialog.
  3. In General properties:

    Database: DBEMP
    Host: 10.221.5.111
    Port Number: 50001
    User Name: user1
    Password: *

  4. Click OK.


But when I tried to connect to the remote database server (AIX v7) via telnet command:

telnet 10.221.5.111

Note: I login using root user.

And then I run this command:

/db2/V10.1/bin/db2 connect to DBEMP

I got this error:

SQL1013N The database alias name or database name "DBEMP" could not be found. SQLSTATE=42705

Then I also run this command:

/db2/V10.1/bin/db2 list database directory

The result list doesn't have database named "DBEMP".


So what happened anyway?

If there is no database name exist, why IBM Data Studio can connect to it?

3
  • 1
    It appears you are referring to DB2 LUW. What are your connection details in Data Studio?
    – WarrenT
    Commented May 10, 2013 at 11:06
  • some of it might be how you telnet into the remote box. Agree with Warren. Please provide more details on how you set up the connection in Data Studio and now it exists on the remote server and how you are connecting to both. Commented May 10, 2013 at 14:20
  • @all: yes, it's LUW. I had added more details in the question.
    – null
    Commented May 13, 2013 at 6:12

2 Answers 2

1

Ahh....That has to do with profiles. Root was not set up by default to have DB2 libraries set up in its profile, so it doesn't recognize the DB2 executables. This is not to say root can't do what you are asking, you would just have to browse to the /instance/bin folder to find the executables you are after. Of course, then you have to worry about whether or not root has permission to connect....

But anyway, you might find it easier to sudo over to the id you want to use to connect (possibly even the instance) sudo - myid. For sure the instance will have DB2 set up in its profile. Your other ID you may have to set it up. Here is an answer I provided before where I showed someone how to set up DB2 for their profile.

I would recommend that you not give root DB2 access through its profile.

5
  • So did you mean I should login using user1 (instead of root) in the telnet session and only then I could connect to the database?
    – null
    Commented May 13, 2013 at 16:04
  • 1
    I'm saying that root doesn't have DB2 set up in its profile. I don't know that user1 does either (it may or may not). You could try logging in as user1 and checking. If you don't have DB2 access you may need to navigate to your DB2 instance directory and invoke the db2profile script. Then you can use DB2. Make sense? Commented May 13, 2013 at 17:00
  • I tried login using user1 and it works. So I guess you're right that the root user doesn't has db2 profile set up, but I wonder where is the db2profile script for root, I can't found it since root doesn't has home directory (the db2profile is in /home/<user_name>/sqllib directory)
    – null
    Commented May 15, 2013 at 5:38
  • I don't believe you would want root running DB2, but if you really wanted to you could just execute the db2profile script. Commented May 16, 2013 at 12:46
  • Don't worry, I don't really want to do that. I'm just curious how to do it if it's really possible. The problem is (like I stated before) I can't find db2profile script for root, because root doesn't has home directory. Another user (like user1) has db2profile script resides in their home directory. Note: the OS is IBM AIX v7.
    – null
    Commented May 16, 2013 at 14:31
1

I'm a beginner in db2 who try to help, I have the same problem too but I've resolved. It maybe caused when you're not store your database to catalog. Here's the command.

db2 catalog db DB_NAME at node YOUR_NODE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.