DB2 连接错误 (database)

错误

DB2 连接错误 (database)_第1张图片

DB2 连接错误 (database)_第2张图片

DB2出现连接错误,初步判定 数据库名 错误。

解决

DB2 中的 每个 schema 实例 并不是 database 名。功能上 schema 相当于 MySQL 中的 database。但是并不代表 DB2 数据库名。

DB2 连接错误 (database)_第3张图片

DB2 查看 database

方法一

在 db2inst1 用户下 使用命令查看

[root@server065 ~]# su - db2inst1
Last login: Thu Jan 25 08:32:21 CST 2024 on pts/1
[db2inst1@server065 ~]$
[db2inst1@server065 ~]$
[db2inst1@server065 ~]$
[db2inst1@server065 ~]$
[db2inst1@server065 ~]$ db2 list db directory


 System Database Directory


 Number of entries in the directory = 1


Database 1 entry:


 Database alias                       = TPCCDB
 Database name                        = TPCCDB
 Local database directory             = /home/db2inst1
 Database release level               = 14.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =


[db2inst1@server065 ~]$

数据库名为 TPCCDB

方法二

在客户端下,使用 SQL 语句 查看

SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1;

DB2 连接错误 (database)_第4张图片

结论

由此可见 DB2 的数据库名 需要查看获得,schema 并不代表 database。

DB2安装完初始化时,会创建数据库(名字自定义,例如TPCCDB),之后在该数据库(TPCCDB)下创建各种实例(schema),  在每个实例下创建表。

你可能感兴趣的:(数据库,dba,database)