Home Database Mysql Tutorial 关于SQL连接语句中的Integrated Security=SSPI/ture/false

关于SQL连接语句中的Integrated Security=SSPI/ture/false

Jun 07, 2016 pm 04:08 PM
about

关于SQL连接语句中的Integrated Security=SSPI/ture/false

解决方法:
即:Security Support Provider Interface
设置Integrated Security为 True 的时候,连接语句前面的 UserID, PW 是不起作用的,即采用windows身份验证模式。
只有设置为 False 或省略该项的时候,才按照 UserID, PW 来连接。
Integrated Security 可以设置为: True, false, yes, no ,这四个的意思很明白了,还可以设置为:sspi ,相当于 True,建议用这个代替 True。

initial catalog与database的区别是什么
        Initial Catalog:
DataBase:
两者没有任何区别只是名称不一样,就好像是人类的真实姓名与曾用名一样。。都可以叫你。

********************************************

Integrated Security=SSPI 这个表示以当前WINDOWS系统用户身去登录SQL SERVER服务器,,如果SQL SERVER服务器不支持这种方式登录时,就会出错。
你可以使用SQL SERVER的用户名和密码进行登录,如:
"Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=数据库名;Data Source=192.168.0.1;User ID=sa;Password=密码"


***************************************************

Integrated  Security    -  或  -    Trusted_Connection  'false'  当为  false  时,将在连接中指定用户  ID  和密码。当为  true  时,将使用当前的  Windows  帐户凭据进行身份验证。  可识别的值为  true、false、yes、no  以及与  true  等效的  sspi(强烈推荐)。 


*************************************************

ADO.net  中数据库连接方式
System.Data.SqlClient.SqlConnection
常用的一些连接字符串(C#代码):

SqlConnection  conn  =  new  SqlConnection(  “Server=(local);Integrated  Security=SSPI;database=Pubs“);

SqlConnection  conn  =  new  SqlConnection(“server=(local)\NetSDK;database=pubs;Integrated  Security=SSPI“);

SqlConnection  conn  =  new  SqlConnection(“Data  Source=localhost;Integrated  Security=SSPI;Initial  Catalog=Northwind;“);

SqlConnection  conn  =  new  SqlConnection(“  data  source=(local);initial  catalog=xr;integrated  security=SSPI;
persist  security  info=False;workstation  id=XURUI;packet  size=4096;  “);

SqlConnection  myConn    =  new  System.Data.SqlClient.SqlConnection(“Persist  Security  Info=False;Integrated
Security=SSPI;database=northwind;server=mySQLServer“);

SqlConnection  conn  =  new  SqlConnection(  “  uid=sa;pwd=passwords;initial  catalog=pubs;data  source=127.0.0.1;Connect  Timeout=900“);

在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: 命名管道提供程序, error: 40 - 无法打开到 SQL Server 的连接)

如果你的机器装了sql2000 那Data Source=.肯定是不行的了
因为实例名2000和2005的默认的是一样的 所以2005的实例肯定不能用Data Source=.表示

查看sql2005的实例名 将Data Source=.\SQLEXPRESS 中的 SQLEXPRESS用你的新实例名替换掉。

 

关于SQL连接语句中的Integrated Security=SSPI/ture/false

我装的是SQL Server 2005 EXPRESS 即VS2008自带的数据库,所以将Data Source写为:

Data Source=.\SQLEXPRESS即可.SQL2000之前用的.号不能在2005上使用.

今天还遇到一个问题,就是SQL 2005 EXPRESS 启用SA账号的问题.搞了半天不能用,尽管已经将SA启用,但是依然登陆不上,后来,将身份验证设置为SQL+Windows验证模式,才能在SQL Server Management Studio Express上登录.

VS2008其实已经自带了数据库,以及数据库驱动了,平时的开发调试完全可以用这个玩.只是没有数据库管理工具,所以无法建表,其实微软提供了免费的管理工具:

安装微软的SQL Server Management Studio Express就可以操作数据库了.

下载

启用SA方法如下,开启MSE,用windows验证登陆,

关于SQL连接语句中的Integrated Security=SSPI/ture/false

 

关于SQL连接语句中的Integrated Security=SSPI/ture/false

关于SQL连接语句中的Integrated Security=SSPI/ture/false

 

这样就能用SA来登录啦,当然可以自己修改密码.

数据库一打开,.NET能够连上数据库,进行正常的数据存取,那么之后的开发就容易多啦.

本文永久更新链接地址:

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72
Performing logical backups using mysqldump in MySQL Performing logical backups using mysqldump in MySQL Jul 06, 2025 am 02:55 AM

mysqldump is a common tool for performing logical backups of MySQL databases. It generates SQL files containing CREATE and INSERT statements to rebuild the database. 1. It does not back up the original file, but converts the database structure and content into portable SQL commands; 2. It is suitable for small databases or selective recovery, and is not suitable for fast recovery of TB-level data; 3. Common options include --single-transaction, --databases, --all-databases, --routines, etc.; 4. Use mysql command to import during recovery, and can turn off foreign key checks to improve speed; 5. It is recommended to test backup regularly, use compression, and automatic adjustment.

Calculating Database and Table Sizes in MySQL Calculating Database and Table Sizes in MySQL Jul 06, 2025 am 02:41 AM

To view the size of the MySQL database and table, you can query the information_schema directly or use the command line tool. 1. Check the entire database size: Execute the SQL statement SELECTtable_schemaAS'Database',SUM(data_length index_length)/1024/1024AS'Size(MB)'FROMinformation_schema.tablesGROUPBYtable_schema; you can get the total size of all databases, or add WHERE conditions to limit the specific database; 2. Check the single table size: use SELECTta

Handling character sets and collations issues in MySQL Handling character sets and collations issues in MySQL Jul 08, 2025 am 02:51 AM

Character set and sorting rules issues are common when cross-platform migration or multi-person development, resulting in garbled code or inconsistent query. There are three core solutions: First, check and unify the character set of database, table, and fields to utf8mb4, view through SHOWCREATEDATABASE/TABLE, and modify it with ALTER statement; second, specify the utf8mb4 character set when the client connects, and set it in connection parameters or execute SETNAMES; third, select the sorting rules reasonably, and recommend using utf8mb4_unicode_ci to ensure the accuracy of comparison and sorting, and specify or modify it through ALTER when building the library and table.

Implementing Transactions and Understanding ACID Properties in MySQL Implementing Transactions and Understanding ACID Properties in MySQL Jul 08, 2025 am 02:50 AM

MySQL supports transaction processing, and uses the InnoDB storage engine to ensure data consistency and integrity. 1. Transactions are a set of SQL operations, either all succeed or all fail to roll back; 2. ACID attributes include atomicity, consistency, isolation and persistence; 3. The statements that manually control transactions are STARTTRANSACTION, COMMIT and ROLLBACK; 4. The four isolation levels include read not committed, read submitted, repeatable read and serialization; 5. Use transactions correctly to avoid long-term operation, turn off automatic commits, and reasonably handle locks and exceptions. Through these mechanisms, MySQL can achieve high reliability and concurrent control.

Connecting to MySQL Database Using the Command Line Client Connecting to MySQL Database Using the Command Line Client Jul 07, 2025 am 01:50 AM

The most direct way to connect to MySQL database is to use the command line client. First enter the mysql-u username -p and enter the password correctly to enter the interactive interface; if you connect to the remote database, you need to add the -h parameter to specify the host address. Secondly, you can directly switch to a specific database or execute SQL files when logging in, such as mysql-u username-p database name or mysql-u username-p database name

Managing Character Sets and Collations in MySQL Managing Character Sets and Collations in MySQL Jul 07, 2025 am 01:41 AM

The setting of character sets and collation rules in MySQL is crucial, affecting data storage, query efficiency and consistency. First, the character set determines the storable character range, such as utf8mb4 supports Chinese and emojis; the sorting rules control the character comparison method, such as utf8mb4_unicode_ci is case-sensitive, and utf8mb4_bin is binary comparison. Secondly, the character set can be set at multiple levels of server, database, table, and column. It is recommended to use utf8mb4 and utf8mb4_unicode_ci in a unified manner to avoid conflicts. Furthermore, the garbled code problem is often caused by inconsistent character sets of connections, storage or program terminals, and needs to be checked layer by layer and set uniformly. In addition, character sets should be specified when exporting and importing to prevent conversion errors

Setting up asynchronous primary-replica replication in MySQL Setting up asynchronous primary-replica replication in MySQL Jul 06, 2025 am 02:52 AM

To set up asynchronous master-slave replication for MySQL, follow these steps: 1. Prepare the master server, enable binary logs and set a unique server-id, create a replication user and record the current log location; 2. Use mysqldump to back up the master library data and import it to the slave server; 3. Configure the server-id and relay-log of the slave server, use the CHANGEMASTER command to connect to the master library and start the replication thread; 4. Check for common problems, such as network, permissions, data consistency and self-increase conflicts, and monitor replication delays. Follow the steps above to ensure that the configuration is completed correctly.

Using Common Table Expressions (CTEs) in MySQL 8 Using Common Table Expressions (CTEs) in MySQL 8 Jul 12, 2025 am 02:23 AM

CTEs are a feature introduced by MySQL8.0 to improve the readability and maintenance of complex queries. 1. CTE is a temporary result set, which is only valid in the current query, has a clear structure, and supports duplicate references; 2. Compared with subqueries, CTE is more readable, reusable and supports recursion; 3. Recursive CTE can process hierarchical data, such as organizational structure, which needs to include initial query and recursion parts; 4. Use suggestions include avoiding abuse, naming specifications, paying attention to performance and debugging methods.

See all articles