SQLEx preSS - 如何为SQL数据文件设置用户名/密码 [英] SQLExpress - How do I set username/password for a sql datafile

查看:147
本文介绍了SQLEx preSS - 如何为SQL数据文件设置用户名/密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,连接到的成员和SQLServer的数据前preSS数据库文件storage.So我有两个.MDF文件。下面是连接字符串:

I have a website that connects to SQLServer Express database files for Membership and data storage.So I have two .mdf files. Here are the connection strings:

public static string ASPNETDB = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.mdf;Integrated Security=True;User Instance=True;User ID=;Password=; ";
public static string Dok = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dok.mdf;Integrated Security=True;User Instance=True;User ID=;Password=; ";

现在删除并重新安装的网站,我在一个连接established.Here部分已经越来越许多错误后的错误:

Now after deleting and reinstalling the website I've been getting numerous errors in the part where a connection is established.Here are the errors:

Unable to open the physical file "C:\Inetpub\wwwroot\BSHHD\App_Data\aspnetdb_log.ldf". 
Operating system error 5: "5(failed to retrieve text for this error. Reason: 1815)".
Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
File activation failure. The physical file name "C:\Inetpub\wwwroot\BSHHD\App_Data  
\aspnetdb_log.ldf" may be incorrect.
The log cannot be rebuilt because there were open transactions/users when the database 
was shutdown, no checkpoint occurred to the database, or the database was read-only.   
This error could occur if the transaction log file was manually deleted or lost due to 
a hardware or environment failure.

由于我没有对网站的任何变化这是非常奇怪的。我刚刚从IIS中删除它并重新安装它。我建议设置用户名和密码,并删除集成安全性。但我不知道如何为数据文件设置用户名/密码。

It's very strange because I did not make any changes to the website. I just deleted it from IIS and reinstalled it. I was suggested to set username and password and remove Integrated Security. But I do not know how to set username/password for a datafile.

推荐答案

数据库的ASPNETDB.mdf添加到与SQL防爆preSS SQL管理工作室
你可以从微软Web平台安装程序下载。

Add the database ASPNETDB.mdf to the SQL Express with SQL Management studio You can download it from Microsoft web platform installer.

打开SQL管理工作室
右键单击数据库>连接>添加密度板和日志文件(preferable你把它们放在其他地方,那么该网站目录。

Open SQL Management studio Right click on Databases > Attach > Add the mdf and log file (Preferable you put them somewhere else then the site directory.

在MSSQL您可以设置用户名和密码很容易,打开SQL管理工作室。

In MSSQL you can set the username and password easily, Open SQL Management studio.

登录到管理工作室:
展开安全性>登录>写点击登录新登录

Login to the Management studio: Expand Security > Logins > Write Click on Logins "New Login"

登录名:例如LogMeIn的
使SQL Server身份验证
设置密码
删除强制

Login Name: For example logmein Make it SQL Server Authentication Set the Passwords Remove the Enforce

在左边,你将有用户映射
选择要连接到并给予写权限,例如数据库,如果此用户可以写,你会想使数据库它datawriter或db_owner这是更高的权限:

On the left side you will have the User Mapping Select the Database you want to connect to and give the write permissions, for example if this user can write to the database you will want to make it datawriter or db_owner which is higher permission:

内置角色数据库是:

公开 - 默认设置授权

public – the default set of authorizations

的db_owner - 允许执行指定数据库的任何操作。

db_owner – allowed to perform any operation of a specified database

db_oddladmin - 允许创建或修改的数据库的新的对象(所谓的DDL
操作);你应该采取的事实通知用户不必有

db_oddladmin – allowed to create or modify the new objects of the database (so-called DDL operations); you should take notice of the fact that the user doesn’t have to have

的db_owner权限做到这一点。

db_owner authorizations to do that

的db_datareader - 允许读取任何表

db_datareader – allowed to read any table

db_datawriter权限 - 允许写任何表

db_datawriter – allowed to write any table

db_denydatareader - 禁止读表(一种公开的授权外卖)

db_denydatareader – banned to read tables (an overt authorization takeaway)

dDb_denydatawriter - 禁止写表

dDb_denydatawriter – banned to write tables

在您添加数据库到SQL:
您可以在web.config中添加

After you add the database to the SQL: You can add in the web.config

<add name="ASPNETDB" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=ASPNETDB.mdf;User ID=yourusername;Password=yourpassword" providerName="System.Data.SqlClient" />
<add name="Dok " connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=dok.mdf;User ID=yourusername;Password=yourpassword" providerName="System.Data.SqlClient" />

或者如果你preFER有它在code像你有它上面也能正常工作。

or if you prefer to have it in the code like you have it above also it can work.

问候,
加布里埃尔

Regards, Gabriel

这篇关于SQLEx preSS - 如何为SQL数据文件设置用户名/密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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