使用Rust/Tiberius连接本地MS-SQL Server失败求助
Rust使用tiberius连接本地SQL Server 2019失败排查
环境信息
- SQL Server版本:
Microsoft SQL Server 2019 (RTM-GDR) (KB5021125) - 15.0.2101.7 (X64) - 已验证可用的C#连接字符串:
Data Source=<PC name>\<instance name>;Initial Catalog=<db name>;User Id=sa;Password=<password>;
- 数据库已启用Windows身份验证和SA账号登录。
问题描述
尝试使用tiberius库结合tokio运行时,通过Rust连接上述SQL Server数据库,测试了多种配置组合(如下方注释代码所示),但始终无法建立连接。
测试代码片段
//let mut config = Config::from_ado_string("<connection string above>").expect("failed"); //let mut config = Config::new(); //config.host("<pc name here>"); //config.host("<pc ip here>"); //config.host("<pc name here>\<instance name here>"); //config.host("localhost"); //config.host("127.0.0.1"); //config.host("0.0.0.0"); //config.port(<port, usually 1433>); //config.instance_name("<instance name here>"); //config.database("<db name>"); //config.authentication(AuthMethod::sql_server("sa", "<password here>")); //config.trust_cert(); let tcp = TcpStream::connect(config.get_addr()).await?;
错误信息
Os { code: 10061, kind: ConnectionRefused, message: "No connection could be made because the target machine actively refused it." }
猜测方向
怀疑问题由实例名导致,无法正确定位到目标主机。
内容的提问来源于stack exchange,提问作者Ramin Rahimzada
相关产品推荐
相关产品推荐

