今天调查了Microsoft SQL Baseline Checklist中的下面几个问题。

  1. Hide Instances
  2. Extended Store Procedures
  3. Maximum Number Of Error Log Files
  4. Remote Access

 

 1.Hide Instances 

  1. “SQL Server 配置管理器”中,展开“SQL Server 网络配置”,右键单击<server instance> 的协议”,然后选择“属性”

  2. 对于新连接,更改会立即生效。

原文:https://msdn.microsoft.com/en-us/library/ms179327.aspx

注意:隐藏数据库实例后,需要在ConnectionString里追加端口号。

● 如何配置数据库监听特定端口?

  1. 在 SQL Server 配置管理器的控制台窗格中,依次展开“SQL Server 网络配置”“<实例名> 的协议”,然后双击 TCP/IP

  2. 右键单击每个地址,再单击“属性”,标识要配置的 IP 地址。

  3. 如果“TCP 动态端口”对话框中包含 0,则表示数据库引擎正在侦听动态端口,请删除 0。

  4. “IPn 属性”区域框的“TCP 端口”框中,键入希望此 IP 地址侦听的端口号,然后单击“确定”

  5. 在控制台窗格中,单击“SQL Server 服务”

  6. 在详细信息窗格中,右键单击“SQL Server (<实例名>)”,再单击“重新启动”以停止并重新启动 SQL Server。

原文:https://msdn.microsoft.com/en-us/library/ms177440.aspx

● ConnectionString中设定端口号方法:

mycomputer.test.xxx.com,1234

参考:http://stackoverflow.com/questions/5294721/how-to-specify-a-port-number-in-sql-server-connection-string

 

2.Extended Store Procedures

● Disable and Enable Extended Store Procedures

 1 use [master]
 2 
 3 EXEC sp_configure 'show advanced options', 1
 4 GO
 5 RECONFIGURE
 6 GO
 7 
 8 SELECT * FROM SYS.configurations WHERE name = 'show advanced options'
 9 
10 -- Disabling xp_cmdshell
11 EXEC sp_configure 'xp_cmdshell',0
12 GO
13 RECONFIGURE
14 GO
15 
16 -- Check the Disabled record.
17 SELECT * FROM sys.configurations WHERE name = 'xp_cmdshell'
18 
19 -- Enabling xp_cmdshell
20 EXEC sp_configure 'xp_cmdshell',1
21 GO
22 RECONFIGURE
23 GO
24 
25 -- Check the Enabled record.
26 SELECT * FROM sys.configurations WHERE name = 'xp_cmdshell'
27 
28 EXEC sp_configure 'show advanced options', 0
29 GO
30 
31 SELECT * FROM SYS.configurations WHERE name = 'show advanced options'

 原文:http://www.c-sharpcorner.com/Blogs/9579/enabling-disabling-xp_cmdshell-in-sql-server.aspx

注意:最好不要修改既存SP的设定。

https://social.msdn.microsoft.com/forums/sqlserver/en-US/17c7569d-85c0-40ca-b921-cd58b31af612/disabling-extended-stored-procedures

 ● revoked from public

use [master]
GO
REVOKE EXECUTE ON [sys].[xp_dirtree] TO [public]
GO

 ● grant to public

use [master]
GO
GRANT EXECUTE ON [sys].[xp_dirtree] TO [public]
GO

 

3.Maximum Number Of Error Log Files

  1. 配置”。

  2. 配置 SQL Server 错误日志”对话框中,从以下选项中进行选择。

    限制错误日志文件在回收之前的数目

    SQL Server 将保留前六个日志的备份,除非选中此选项并在下面指定一个不同的最大错误日志文件数。

    最大错误日志文件数

    默认值为 6,即 SQL Server 在回收备份日志前保留的以前备份日志的数量。

原文:https://msdn.microsoft.com/en-us/library/ms177285.aspx

 设定:

USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'NumErrorLogs', REG_DWORD, 12
GO

还原:

USE [master]
GO
EXEC xp_instance_regdeletevalue N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'NumErrorLogs'
GO

 

4.Remote Access

1.在对象资源管理器中,右键数据库,点击“Properties”。

2.点击“Connections”标签。

3.把“Allow remote connections to this server”的勾去掉。

参考:http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx

设定:

EXEC sys.sp_configure N'remote access', N'0'
GO
RECONFIGURE WITH OVERRIDE
GO

还原:

EXEC sys.sp_configure N'remote access', N'1'
GO
RECONFIGURE WITH OVERRIDE
GO

 

附1.命令行调用SQL文件(SqlServer)

set user="userid"
set password="password"
set server="sbserver\instance"

osql -U %user% -P %password% -S %server% -i "Setup\SqlFileName.sql" >> logfile.log

 

相关文章:

  • 2021-12-15
  • 2021-08-06
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2021-05-08
  • 2021-06-20
  • 2021-08-08
猜你喜欢
  • 2021-05-23
  • 2022-12-23
  • 2021-07-14
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
相关资源
相似解决方案