数据库链接-无效的用户名/密码

时间:2018-08-09 16:07:37

标签: sql oracle12c

我的计算机上有两个数据库:orcl和orcl1。

我从orcl1创建了以下数据库链接:

create public database link remote_connect
connect to system identified by ***
using 'orcl';

然后我运行以下查询:

SQL> select * from test@remote_connect;
select * from test@remote_connect
                   *
ERROR at line 1:
ORA-01017: invalid username/password; logon denied
ORA-02063: preceding line from REMOTE_CONNECT

我已经确保用户名和密码正确无误,因为我使用它们来登录orcl。有什么问题,我该怎么解决?

编辑:

我的tnsnames.ora文件在orcl1目录中如下所示:

ORCL1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl1)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl1)
    )
  )

我的tnsnames.ora文件在orcl目录下看起来像这样:

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

ORCL1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

1 个答案:

答案 0 :(得分:1)

您可能会发现,使用简单连接语法比使用TNS别名更简单,因为使用它们似乎使您不清楚实际上要连接到哪个数据库。

您可以执行以下操作:

create public database link remote_connect
connect to system identified by ***
using '//localhost:1521/orcl';