电脑技术学习

SQL SERVER 2005 EXPRESS不能远程连接的问题

dn001

错误提示:"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) "

装完 sqlserver2005(Express版),为了便于管理,你还需要去下一个管理器(SQLServer2005_SSMSEE.msi),微软的官方网站有。

1、开启sql2005远程连接功能:
配置工具->SQL Server 外围应用配置器->服务和连接的外围应用配置器->打开MSSQLSERVER节点下的Database Engine 节点,先择"远程连接",接下建议选择"同时使用TCP/IP和named pipes",确定后,重启数据库服务.

2、登陆改为混合模式:
打开manage管理器->以windows方式连接并进入数据库->右键点击你的数据服务器->属性->security>选中Sql server and windows Authentication

3、新建Sql server方式的用户名和密码:
maage管理器->security->右键点击logins->new login...->选中sql server authentication->设置login name 和password(confirm password)
最好去掉“enforce password expiration”前的小钩,否则每次登陆都要修改密码。
/*
manage管理器->windows Authentication>new query>sp_password null,'sa123456','sa'
这样就设置了一个用户名为sa ,密码为:sa123456的用户,下次在登陆时,可以用Sql server方式,
用户名为sa ,密码为:sa123456的用户进数据库了.
*/

4、做完上面三步后,这样写连接字符串就可以顺利进入数据库了(server=.sqlexpress;uid=用户名;pwd=密码;database=master");

搞了半天原来我一直写的server=(local),晕倒。

标签: