查看: 2131|回复: 0

[SQLServer] 配置SQL Server on Linux(1)

发表于 2018-1-8 08:00:02
1. 前言

SQL Server一般是在安装过程中进行相关的配置,安装完成之后,再去修改有一些配置就比较麻烦,比如更改SQL Server实例级别的排序规则。但在Linux下,安装过程并没有很多可以配置的步骤,安装步骤变得很简单,更多的配置可以通过/opt/mssql/bin/mssql-conf工具进行。

2. 环境

Linux: CentOS 7.4,SQL Server 2017 (RC2) - 14.0.900.75 (X64)

3. 更改SQL Server排序规则 步骤如下:
  1. 备份所有用户数据库。(如果是刚刚安装好的实例没有用户数据库可以跳过这一步。)
  2. 停止数据库实例
  3. 运行/opt/mssql/bin/mssql-conf set-collation命令修改排序规则
  4. 启动数据库实例
  5. 还原用户数据库(没有用户数据库可跳过)

下面就来演示下。

查询当前数据库实例的排序规则

  1. 1> SELECT CONVERT(NVARCHAR(50),SERVERPROPERTY('Collation'));
  2. 2> GO
  3. --------------------------------------------------
  4. SQL_Latin1_General_CP1_CI_AS
复制代码

Code-1: 更改前的数据库实例排序规则

使用sp_detach_db存储过程来分离数据库。如果提示数据库正在使用,可以设置数据库为单用户模式,或者干脆就把数据库实例重启。

  1. 1> exec sp_detach_db db1;
  2. 2> go
  3. 1> exec sp_detach_db AdventureWorks2014;
  4. 2> go
  5. 1> exec sp_detach_db AdventureWorks2017;
  6. 2> go
复制代码

Code-2:分离用户数据库

在shell 下:

  1. [root@134test ~]# systemctl stop mssql-server
  2. [root@134test ~]# /opt/mssql/bin/mssql-conf set-collation
  3. Enter the collation: Chinese_PRC_CI_AS
  4. Configuring SQL Server...
  5. This is an evaluation version. There are [27] days left in the evaluation period.
  6. 2017-12-27 10:31:21.81 Server Microsoft SQL Server 2017 (RC2) - 14.0.900.75 (X64)
  7. Jul 27 2017 08:53:49
  8. Copyright (C) 2017 Microsoft Corporation
  9. Developer Edition (64-bit) on Linux (CentOS Linux 7 (Core))
  10. 2017-12-27 10:31:21.82 Server UTC adjustment: 8:00
  11. 2017-12-27 10:31:21.82 Server (c) Microsoft Corporation.
  12. 2017-12-27 10:31:21.82 Server All rights reserved.
  13. 2017-12-27 10:31:21.82 Server Server process ID is 4120.
  14. 2017-12-27 10:31:21.82 Server Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
  15. 2017-12-27 10:31:21.83 Server Registry startup parameters:
  16. -d /var/opt/mssql/data/master.mdf
  17. -l /var/opt/mssql/data/mastlog.ldf
  18. -e /var/opt/mssql/log/errorlog
  19. 2017-12-27 10:31:21.83 Server Command Line Startup Parameters:
  20. -q "Chinese_PRC_CI_AS"
  21. 2017-12-27 10:31:21.83 Server SQL Server detected 1 sockets with 4 cores per socket and 4 logical processors per socket, <br>4 total logical processors; using 4 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
  22. 2017-12-27 10:31:21.84 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
  23. 2017-12-27 10:31:21.84 Server Detected 3027 MB of RAM. This is an informational message; no user action is required.
  24. 2017-12-27 10:31:21.84 Server Using conventional memory in the memory manager.
  25. 2017-12-27 10:31:22.36 Server Buffer pool extension is already disabled. No action is necessary.
  26. 2017-12-27 10:31:22.63 Server Perfmon counters for resource governor pools and groups failed to initialize and are disabled.
  27. 2017-12-27 10:31:22.67 Server InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
  28. 2017-12-27 10:31:22.67 Server Implied authentication manager initialization failed. Implied authentication will be disabled.
  29. 2017-12-27 10:31:22.69 Server Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2']. <br>Allowed TLS ciphers are ['ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:<br>ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:<br>AES128-SHA256:AES256-SHA:AES128-SHA:!DHE-RSA-AES256-GCM-SHA384:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES256-SHA:!DHE-RSA-AES128-SHA'].
  30. 2017-12-27 10:31:22.76 Server The maximum number of dedicated administrator connections for this instance is '1'
  31. 2017-12-27 10:31:22.76 Server Node configuration: node 0: CPU mask: 0x000000000000000f:0 Active CPU mask: 0x000000000000000f:0. <br>This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
  32. 2017-12-27 10:31:22.77 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. <br>This is an informational message only. No user action is required.
  33. 2017-12-27 10:31:22.79 Server In-Memory OLTP initialized on lowend machine.
  34. 2017-12-27 10:31:22.84 Server Database Instant File Initialization: enabled. For security and performance considerations see the topic <br>'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
  35. 2017-12-27 10:31:22.85 Server Database Mirroring Transport is disabled in the endpoint configuration.
  36. 2017-12-27 10:31:22.85 spid5s Warning ******************
  37. 2017-12-27 10:31:22.86 spid5s SQL Server started in single-user mode. This an informational message only. No user action is required.
  38. 2017-12-27 10:31:22.86 Server Query Store settings initialized with enabled = 1,
  39. 2017-12-27 10:31:22.86 spid5s Starting up database 'master'.
  40. 2017-12-27 10:31:22.87 Server Software Usage Metrics is disabled.
  41. 2017-12-27 10:31:23.47 spid5s Buffer pool extension is already disabled. No action is necessary.
  42. 2017-12-27 10:31:23.47 spid5s SQL Server Audit is starting the audits. This is an informational message. No user action is required.
  43. 2017-12-27 10:31:23.49 spid5s SQL Server Audit has started the audits. This is an informational message. No user action is required.
  44. 2017-12-27 10:31:23.68 spid5s SQL Trace ID 1 was started by login "sa".
  45. 2017-12-27 10:31:23.68 spid5s Server name is '134test'. This is an informational message only. No user action is required.
  46. 2017-12-27 10:31:23.70 spid5s Always On Availability Groups was not started because the SQL Server instance is running in single-user mode. <br>This is an informational message. No user action is required.
  47. 2017-12-27 10:31:23.71 spid5s Starting up database 'msdb'.
  48. 2017-12-27 10:31:23.72 spid9s Starting up database 'mssqlsystemresource'.
  49. 2017-12-27 10:31:23.75 spid9s The resource database build version is 14.00.900. This is an informational message only. No user action is required.
  50. 2017-12-27 10:31:23.79 spid9s Starting up database 'model'.
  51. 2017-12-27 10:31:24.04 spid5s Recovery is writing a checkpoint in database 'msdb' (4). This is an informational message only. No user action is required.
  52. 2017-12-27 10:31:24.12 spid9s Polybase feature disabled.
  53. 2017-12-27 10:31:24.12 spid9s Clearing tempdb database.
  54. 2017-12-27 10:31:24.33 spid17s A self-generated certificate was successfully loaded for encryption.
  55. 2017-12-27 10:31:24.34 spid17s Server is listening on [ 'any' <ipv6> 1433].
  56. 2017-12-27 10:31:24.35 spid17s Server is listening on [ 'any' <ipv4> 1433].
  57. 2017-12-27 10:31:24.35 Server Server is listening on [ ::1 <ipv6> 1434].
  58. 2017-12-27 10:31:24.36 Server Server is listening on [ 127.0.0.1 <ipv4> 1434].
  59. 2017-12-27 10:31:24.36 Server Dedicated admin connection support was established for listening locally on port 1434.
  60. 2017-12-27 10:31:24.39 spid17s SQL Server is now ready for client connections. This is an informational message; no user action is required.
  61. 2017-12-27 10:31:24.99 spid9s Starting up database 'tempdb'.
  62. 2017-12-27 10:31:25.12 spid9s The tempdb database has 1 data file(s).
  63. 2017-12-27 10:31:25.18 spid5s Warning ******************
  64. 2017-12-27 10:31:25.18 spid5s Attempting to change default collation to Chinese_PRC_CI_AS.
  65. 2017-12-27 10:31:25.22 spid5s index restored for master.syspriorities.
  66. 2017-12-27 10:31:25.23 spid5s index restored for master.sysbrickfiles.
  67. 2017-12-27 10:31:25.23 spid5s index restored for master.sysprufiles.
  68. 2017-12-27 10:31:25.23 spid5s index restored for master.sysowners.
  69. 2017-12-27 10:31:25.23 spid5s index restored for master.sysdbreg.
  70. 2017-12-27 10:31:25.24 spid5s index restored for master.sysschobjs.
  71. 2017-12-27 10:31:25.25 spid5s index restored for master.sysextsources.
  72. 2017-12-27 10:31:25.25 spid5s index restored for master.sysextfileformats.
  73. 2017-12-27 10:31:25.25 spid5s index restored for master.syscolpars.
  74. 2017-12-27 10:31:25.25 spid5s index restored for master.sysxlgns.
  75. 2017-12-27 10:31:25.25 spid5s index restored for master.sysxsrvs.
  76. 2017-12-27 10:31:25.26 spid5s index restored for master.sysnsobjs.
  77. 2017-12-27 10:31:25.26 spid5s index restored for master.syscerts.
  78. 2017-12-27 10:31:25.26 spid5s index restored for master.sysrmtlgns.
  79. 2017-12-27 10:31:25.26 spid5s index restored for master.sysxprops.
  80. 2017-12-27 10:31:25.26 spid5s index restored for master.sysscalartypes.
  81. 2017-12-27 10:31:25.26 spid5s index restored for master.sysidxstats.
  82. 2017-12-27 10:31:25.27 spid5s index restored for master.sysendpts.
  83. 2017-12-27 10:31:25.27 spid5s index restored for master.sysclsobjs.
  84. 2017-12-27 10:31:25.27 spid5s index restored for master.sysremsvcbinds.
  85. 2017-12-27 10:31:25.27 spid5s index restored for master.sysrts.
  86. 2017-12-27 10:31:25.27 spid5s index restored for master.sysasymkeys.
  87. 2017-12-27 10:31:25.27 spid5s index restored for master.syssqlguides.
  88. 2017-12-27 10:31:25.27 spid5s index restored for master.syssoftobjrefs.
  89. 2017-12-27 10:31:25.28 spid5s index restored for master.MSreplication_options.
  90. 2017-12-27 10:31:25.31 spid5s index restored for tempdb.syspriorities.
  91. 2017-12-27 10:31:25.32 spid5s index restored for tempdb.sysowners.
  92. 2017-12-27 10:31:25.32 spid5s index restored for tempdb.sysdbreg.
  93. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysschobjs.
  94. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysextsources.
  95. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysextfileformats.
  96. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.syscolpars.
  97. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysxlgns.
  98. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysxsrvs.
  99. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysnsobjs.
  100. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.syscerts.
  101. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysrmtlgns.
  102. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysxprops.
  103. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysscalartypes.
  104. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysidxstats.
  105. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysendpts.
  106. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysclsobjs.
  107. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.sysremsvcbinds.
  108. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.sysrts.
  109. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.sysasymkeys.
  110. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.syssqlguides.
  111. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.syssoftobjrefs.
  112. 2017-12-27 10:31:25.39 spid5s index restored for model.syspriorities.
  113. 2017-12-27 10:31:25.40 spid5s index restored for model.sysowners.
  114. 2017-12-27 10:31:25.40 spid5s index restored for model.sysdbreg.
  115. 2017-12-27 10:31:25.42 spid5s index restored for model.sysschobjs.
  116. 2017-12-27 10:31:25.42 spid5s index restored for model.sysextsources.
  117. 2017-12-27 10:31:25.42 spid5s index restored for model.sysextfileformats.
  118. 2017-12-27 10:31:25.43 spid5s index restored for model.syscolpars.
  119. 2017-12-27 10:31:25.43 spid5s index restored for model.sysxlgns.
  120. 2017-12-27 10:31:25.44 spid5s index restored for model.sysxsrvs.
  121. 2017-12-27 10:31:25.44 spid5s index restored for model.sysnsobjs.
  122. 2017-12-27 10:31:25.44 spid5s index restored for model.syscerts.
  123. 2017-12-27 10:31:25.45 spid5s index restored for model.sysrmtlgns.
  124. 2017-12-27 10:31:25.45 spid5s index restored for model.sysxprops.
  125. 2017-12-27 10:31:25.45 spid5s index restored for model.sysscalartypes.
  126. 2017-12-27 10:31:25.46 spid5s index restored for model.sysidxstats.
  127. 2017-12-27 10:31:25.46 spid5s index restored for model.sysendpts.
  128. 2017-12-27 10:31:25.47 spid5s index restored for model.sysclsobjs.
  129. 2017-12-27 10:31:25.47 spid5s index restored for model.sysremsvcbinds.
  130. 2017-12-27 10:31:25.48 spid5s index restored for model.sysrts.
  131. 2017-12-27 10:31:25.48 spid5s index restored for model.sysasymkeys.
  132. 2017-12-27 10:31:25.48 spid5s index restored for model.syssqlguides.
  133. 2017-12-27 10:31:25.48 spid5s index restored for model.syssoftobjrefs.
  134. 2017-12-27 10:31:25.83 spid5s index restored for msdb.syspriorities.
  135. 2017-12-27 10:31:25.84 spid5s index restored for msdb.sysowners.
  136. 2017-12-27 10:31:25.84 spid5s index restored for msdb.sysdbreg.
  137. 2017-12-27 10:31:25.90 spid5s index restored for msdb.sysschobjs.
  138. 2017-12-27 10:31:25.90 spid5s index restored for msdb.sysextsources.
  139. 2017-12-27 10:31:25.90 spid5s index restored for msdb.sysextfileformats.
  140. 2017-12-27 10:31:25.96 spid5s index restored for msdb.syscolpars.
  141. 2017-12-27 10:31:25.96 spid5s index restored for msdb.sysxlgns.
  142. 2017-12-27 10:31:25.96 spid5s index restored for msdb.sysxsrvs.
  143. 2017-12-27 10:31:25.97 spid5s index restored for msdb.sysnsobjs.
  144. 2017-12-27 10:31:25.97 spid5s index restored for msdb.syscerts.
  145. 2017-12-27 10:31:25.97 spid5s index restored for msdb.sysrmtlgns.
  146. 2017-12-27 10:31:25.98 spid5s index restored for msdb.sysxprops.
  147. 2017-12-27 10:31:25.99 spid5s index restored for msdb.sysscalartypes.
  148. 2017-12-27 10:31:26.00 spid5s index restored for msdb.sysidxstats.
  149. 2017-12-27 10:31:26.00 spid5s index restored for msdb.sysendpts.
  150. 2017-12-27 10:31:26.01 spid5s index restored for msdb.sysclsobjs.
  151. 2017-12-27 10:31:26.01 spid5s index restored for msdb.sysremsvcbinds.
  152. 2017-12-27 10:31:26.02 spid5s index restored for msdb.sysrts.
  153. 2017-12-27 10:31:26.02 spid5s index restored for msdb.sysasymkeys.
  154. 2017-12-27 10:31:26.02 spid5s index restored for msdb.syssqlguides.
  155. 2017-12-27 10:31:26.04 spid5s index restored for msdb.syssoftobjrefs.
  156. 2017-12-27 10:31:26.05 spid5s index restored for msdb.syscachedcredentials.
  157. 2017-12-27 10:31:26.06 spid5s index restored for msdb.syscollector_blobs_internal.
  158. 2017-12-27 10:31:26.07 spid5s index restored for msdb.syspolicy_system_health_state_internal.
  159. 2017-12-27 10:31:26.10 spid5s index restored for msdb.sysmanagement_shared_server_groups_internal.
  160. 2017-12-27 10:31:26.11 spid5s index restored for msdb.sysssispackages.
  161. 2017-12-27 10:31:26.12 spid5s index restored for msdb.sysmanagement_shared_registered_servers_internal.
  162. 2017-12-27 10:31:26.03 spid5s index restored for msdb.sysssispackagefolders.
  163. 2017-12-27 10:31:26.04 spid5s index restored for msdb.sysutility_mi_smo_properties_to_collect_internal.
  164. 2017-12-27 10:31:26.05 spid5s index restored for msdb.syspolicy_configuration_internal.
  165. 2017-12-27 10:31:26.06 spid5s index restored for msdb.log_shipping_primary_databases.
  166. 2017-12-27 10:31:26.08 spid5s index restored for msdb.syspolicy_management_facets.
  167. 2017-12-27 10:31:26.10 spid5s index restored for msdb.syspolicy_facet_events.
  168. 2017-12-27 10:31:26.11 spid5s index restored for msdb.syscollector_config_store_internal.
  169. 2017-12-27 10:31:26.12 spid5s index restored for msdb.sysutility_ucp_dac_health_internal.
  170. 2017-12-27 10:31:26.12 spid5s index restored for msdb.sysmail_profile.
  171. 2017-12-27 10:31:26.13 spid5s index restored for msdb.MSdbms.
  172. 2017-12-27 10:31:26.14 spid5s index restored for msdb.log_shipping_primary_secondaries.
  173. 2017-12-27 10:31:26.16 spid5s index restored for msdb.syspolicy_conditions_internal.
  174. 2017-12-27 10:31:26.17 spid5s index restored for msdb.MSdbms_datatype.
  175. 2017-12-27 10:31:26.17 spid5s index restored for msdb.log_shipping_monitor_primary.
  176. 2017-12-27 10:31:26.18 spid5s index restored for msdb.log_shipping_monitor_history_detail.
  177. 2017-12-27 10:31:26.19 spid5s index restored for msdb.log_shipping_monitor_error_detail.
  178. 2017-12-27 10:31:26.19 spid5s index restored for msdb.log_shipping_secondary.
  179. 2017-12-27 10:31:26.20 spid5s index restored for msdb.log_shipping_secondary_databases.
  180. 2017-12-27 10:31:26.21 spid5s index restored for msdb.sysutility_ucp_managed_instances_internal.
  181. 2017-12-27 10:31:26.22 spid5s index restored for msdb.log_shipping_monitor_secondary.
  182. 2017-12-27 10:31:26.23 spid5s index restored for msdb.sysmail_account.
  183. 2017-12-27 10:31:26.23 spid5s index restored for msdb.sysutility_ucp_mi_health_internal.
  184. 2017-12-27 10:31:26.24 spid5s index restored for msdb.sysdac_instances_internal.
  185. 2017-12-27 10:31:26.26 spid5s index restored for msdb.syscollector_collection_sets_internal.
  186. 2017-12-27 10:31:26.27 spid5s index restored for msdb.syspolicy_policy_categories_internal.
  187. 2017-12-27 10:31:26.27 spid5s index restored for msdb.sysdac_history_internal.
  188. 2017-12-27 10:31:26.29 spid5s index restored for msdb.sysmail_servertype.
  189. 2017-12-27 10:31:26.31 spid5s index restored for msdb.syspolicy_object_sets_internal.
  190. 2017-12-27 10:31:26.32 spid5s index restored for msdb.sysutility_ucp_health_policies_internal.
  191. 2017-12-27 10:31:26.33 spid5s index restored for msdb.sysmail_server.
  192. 2017-12-27 10:31:26.33 spid5s index restored for msdb.sysutility_ucp_filegroups_with_policy_violations_internal.
  193. 2017-12-27 10:31:26.35 spid5s index restored for msdb.sysutility_ucp_policy_check_conditions_internal.
  194. 2017-12-27 10:31:26.36 spid5s index restored for msdb.syscollector_collector_types_internal.
  195. 2017-12-27 10:31:26.38 spid5s index restored for msdb.syspolicy_policies_internal.
  196. 2017-12-27 10:31:26.38 spid5s index restored for msdb.sysutility_ucp_policy_target_conditions_internal.
  197. 2017-12-27 10:31:26.39 spid5s index restored for msdb.sysmail_configuration.
  198. 2017-12-27 10:31:26.40 spid5s index restored for msdb.external_libraries_installed.
  199. 2017-12-27 10:31:26.41 spid5s index restored for msdb.sysdbmaintplan_databases.
  200. 2017-12-27 10:31:26.42 spid5s index restored for msdb.sysutility_ucp_configuration_internal.
  201. 2017-12-27 10:31:26.43 spid5s index restored for msdb.sysproxies.
  202. 2017-12-27 10:31:26.45 spid5s index restored for msdb.syssubsystems.
  203. 2017-12-27 10:31:26.46 spid5s index restored for msdb.syscollector_collection_items_internal.
  204. 2017-12-27 10:31:26.47 spid5s index restored for msdb.sysdownloadlist.
  205. 2017-12-27 10:31:26.48 spid5s index restored for msdb.sysoriginatingservers.
  206. 2017-12-27 10:31:26.50 spid5s index restored for msdb.autoadmin_managed_databases.
  207. 2017-12-27 10:31:26.51 spid5s index restored for msdb.sysjobs.
  208. 2017-12-27 10:31:26.53 spid5s index restored for msdb.smart_backup_files.
  209. 2017-12-27 10:31:26.56 spid5s index restored for msdb.backupset.
  210. 2017-12-27 10:31:26.58 spid5s index restored for msdb.sysjobsteps.
  211. 2017-12-27 10:31:26.59 spid5s index restored for msdb.syscollector_execution_stats_internal.
  212. 2017-12-27 10:31:26.59 spid5s index restored for msdb.sysutility_ucp_mi_file_space_health_internal.
  213. 2017-12-27 10:31:26.61 spid5s index restored for msdb.syspolicy_target_sets_internal.
  214. 2017-12-27 10:31:26.62 spid5s index restored for msdb.sysschedules.
  215. 2017-12-27 10:31:26.63 spid5s index restored for msdb.sysutility_ucp_mi_database_health_internal.
  216. 2017-12-27 10:31:26.64 spid5s index restored for msdb.logmarkhistory.
  217. 2017-12-27 10:31:26.64 spid5s index restored for msdb.sysutility_ucp_dac_file_space_health_internal.
  218. 2017-12-27 10:31:26.65 spid5s index restored for msdb.syscategories.
  219. 2017-12-27 10:31:26.66 spid5s index restored for msdb.systargetservers.
  220. 2017-12-27 10:31:26.67 spid5s index restored for msdb.sysutility_ucp_mi_volume_space_health_internal.
  221. 2017-12-27 10:31:26.67 spid5s index restored for msdb.sysutility_mi_dac_execution_statistics_internal.
  222. 2017-12-27 10:31:26.68 spid5s index restored for msdb.systargetservergroups.
  223. 2017-12-27 10:31:26.69 spid5s index restored for msdb.syspolicy_policy_category_subscriptions_internal.
  224. 2017-12-27 10:31:26.69 spid5s index restored for msdb.sysalerts.
  225. 2017-12-27 10:31:26.70 spid5s index restored for msdb.sysutility_ucp_computer_cpu_health_internal.
  226. 2017-12-27 10:31:26.70 spid5s index restored for msdb.sysutility_mi_session_statistics_internal.
  227. 2017-12-27 10:31:26.71 spid5s index restored for msdb.sysoperators.
  228. 2017-12-27 10:31:26.73 spid5s The default collation was successfully changed.
  229. 2017-12-27 10:31:26.73 spid5s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
  230. The server collation has been changed.
  231. Please run 'sudo systemctl start mssql-server' to start SQL Server.
复制代码

Code-3:更改排序规则

  1. [root@134test ~]# systemctl start mssql-server
复制代码

Code-4:重启数据库实例

查询当前数据库实例的排序规则

  1. 1> SELECT CONVERT(NVARCHAR(50),SERVERPROPERTY('Collation'));
  2. 2> GO
  3. --------------------------------------------------
  4. Chinese_PRC_CI_AS
复制代码

Code-5:更改后的数据库实例排序规则

还原用户数据库

  1. 1> exec sp_attach_db 'db1','/data/mssql_data/db1.mdf','/data/mssql_data/db1_log.ldf';
  2. 2> go
  3. 1> exec sp_attach_db 'AdventureWorks2014','/data/mssql_data/AdventureWorks2014.mdf','/data/mssql_data/AdventureWorks2014_log.ldf';
  4. 2> go
  5. 1> exec sp_attach_db 'AdventureWorks2017','/data/mssql_data/AdventureWorks2017.mdf','/data/mssql_data/AdventureWorks2017_log.ldf';
  6. 2> go
复制代码

Code-6:还原数据库

查询当前数据库的排序规则

  1. 1> SELECT CONVERT(NVARCHAR(30),name), CONVERT(NVARCHAR(50),collation_name) FROM sys.databases;
  2. 2> GO
  3. ------------------------------ --------------------------------------------------
  4. master Chinese_PRC_CI_AS
  5. tempdb Chinese_PRC_CI_AS
  6. model Chinese_PRC_CI_AS
  7. msdb Chinese_PRC_CI_AS
  8. db1 SQL_Latin1_General_CP1_CI_AS
  9. AdventureWorks2014 SQL_Latin1_General_CP1_CI_AS
  10. AdventureWorks2017 SQL_Latin1_General_CP1_CI_AS
  11. (7 rows affected)
复制代码

Code-7:所有数据库的排序规则

4. 参考

https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-configure-mssql-conf

https://docs.microsoft.com/zh-cn/sql/relational-databases/system-stored-procedures/sp-detach-db-transact-sql

https://docs.microsoft.com/zh-cn/sql/relational-databases/system-stored-procedures/sp-attach-db-transact-sql



回复

使用道具 举报