我有 2 台使用 Firebird 2.5 的服务器。每台服务器都有一个单独的数据库,其中一台连接到另一台服务器以检索一些数据。其中一台服务器切换到 Firebird 3.0,现在无法连接到 2.5 服务器。它说我的用户名或密码不正确。我已使用凭据连接到 2.5 服务器,一切正常。
为了检索数据,我使用了
Execute statement [STATEMENT] on external Datasource [SERVER] as user [USER] password [PASSWORD]
。
Firebird 2.5服务器数据库较多,升级到Firebird 3.0比较麻烦。
如何解决这个问题?
我已经使用以下简单语句(并根据我正在测试的内容修改了一些部分)在同一服务器上使用不同端口对 Firebird 2.5 (2.5.8) 和 Firebird 3 (3.0.4) 进行了一些测试,以查看我会产生什么样的连接故障。
set term #;
execute block returns (tblname char(31))
as
begin
for execute statement 'select rdb$relation_name from rdb$relations where coalesce(rdb$system_flag, 0) = 0'
on external data source 'localhost/3051:D:\data\db\testdatabase.fdb'
as user 'sysdba' password 'masterkey'
into tblname
do suspend;
end#
set term ;#
使用此语句,在以下情况下,从 Firebird 3 到 2.5,我会收到错误 “您的用户名和密码未定义。”:
Firebird 3 具有
AuthClient
1 配置,但不包括 Legacy_Auth
。 Firebird 3 无法向 Firebird 2.5 进行身份验证,因为 Firebird 2.5 只知道旧的身份验证机制。
要解决此问题,请将
Legacy_Auth
添加到 Firebird 3 服务器的 AuthClient
中的 firebird.conf
设置(例如将其设置为 AuthClient = Srp, Legacy_Auth
)并重新启动服务器。
这一点很可能是你的问题。
未指定用户名和密码(即将
as user 'sysdba' password 'masterkey'
排除在 execute statement
之外)。这可能是由于身份验证机制的差异,因为 Firebird 不知道 SRP 协议的实际密码,因此无法向其他服务器进行身份验证。
指定用户名和密码可以解决此问题。
反向(Firebird 2.5 至 3),在以下情况下无法建立连接:
使用仅作为 Srp 用户存在的用户名和密码进行身份验证。这会导致错误“您的用户名和密码未定义。”,因为 Firebird 2.5 仅支持旧版身份验证,因此只能对 Firebird 3 中的 Legacy_UserManager 插件存在的用户进行身份验证。
为 Legacy_UserManager 插件创建一个用户(可以使用相同的名称或不同的名称):
create user theuser password 'thepassword' using plugin Legacy_UserManager;
commit;
如果这导致错误 “缺少请求的管理插件”,那么您需要编辑 Firebird 3
firebird.conf
并将 Legacy_UserManager
添加到 UserManager
设置(例如设置为 UserManager = Srp, Legacy_UserManager
;默认仅为 Srp
)并重新启动 Firebird。
作为 SYSDBA,您可以通过执行在 Firebird 3 服务器上检查用户存在哪个插件(或多个插件!)
select SEC$USER_NAME, SEC$PLUGIN
from SEC$USERS
Firebird 3 有设置
WireCrypt = Required
(这是默认设置!)。这会产生错误 “连接被远程接口拒绝”。
要解决此问题,请在 Firebird 3 服务器的
WireCrypt = Enabled
中设置 firebird.conf
并重新启动服务器。
未指定用户名和密码(即将
as user 'sysdba' password 'masterkey'
排除在 execute statement
之外)。这会产生错误 “未知 ISC 错误 335545106”(实际消息为 “登录期间发生错误,请检查服务器 firebird.log 了解详细信息” 如果使用 Firebird 3 消息文件),其中 Firebird 3 的日志显示 “服务器上没有匹配的插件”,这可能是由于身份验证机制的差异。
指定用户名和密码可以解决此问题。
Firebird 3 具有
AuthServer
配置,不包括 Legacy_Auth
(默认仅包含 Srp
!)。这还会产生错误 “未知 ISC 错误 335545106”(实际消息是 “登录期间发生错误,请检查服务器 firebird.log 了解详细信息” 如果使用 Firebird 3 消息文件),其中 Firebird 3 的日志显示 “服务器上没有匹配的插件”.
要解决此问题,请将
Legacy_Auth
添加到 Firebird 3 服务器的 AuthServer
中的 firebird.conf
设置(例如将其设置为 AuthServer = Srp, Legacy_Auth
)并重新启动服务器。
当然,双向错误“您的用户名和密码未定义。”也可以通过使用不存在的用户或错误的密码来产生。