无法使用 py2exe 以“域\计算机名"pyodbc 身份登录 [英] Failed to Login as 'Domain\ComputerName' pyodbc with py2exe

查看:40
本文介绍了无法使用 py2exe 以“域\计算机名"pyodbc 身份登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我有一个连接到 mssql 数据库的脚本,我需要作为我已经完成的服务运行,但是当我将它作为服务运行时,它会覆盖我在连接到db 与广告计算机帐户.

Ok so I have a script that connects to a mssql db and i need to run as a service which I have already accomplished but when I run it as a service it overrides my credentials that I have put in when i connect to the db with the ad computer account.

当我单独运行而不是作为服务运行时,它运行得很好.

It runs perfect when i run it on its own and not as a service.

我的连接字符串是:

<代码>'DRIVER={SQL Server};SERVER=MyServer;DATABASE=MyDB;UID=DOMAIN\myusername;PWD=A;Trusted_Connection=True'

错误是:

<代码>错误: ('28000', "[28000] [Microsoft][ODBC SQL Server 驱动程序][SQL Server]用户 'DOMAIN\COMPUTERNAME' 登录失败)

有什么建议吗?

推荐答案

以下连接字符串将使用 Windows 身份验证,使用运行该服务的帐户向数据库进行身份验证.将服务帐户更改为具有数据库访问权限的帐户:

The following connection string will use Windows authentication, using the account running the service to authenticate with the database. Change the service account to one that has database access:

'DRIVER={SQL Server};SERVER=SERVERNAME;DATABASE=DBName;Trusted_Connection=yes'

更改服务帐户:

  • 开始 -> 运行 -> services.msc
  • 右键单击服务 -> 属性
  • 登录标签
  • 确定/应用以保存更改

这篇关于无法使用 py2exe 以“域\计算机名"pyodbc 身份登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆