当前位置: 首页 > 工具软件 > Free-SA > 使用案例 >

Linux下sqlserver SA密码忘记了破解方法

程冥夜
2023-12-01

1.停止mssql-server服务

systemctl stop mssql-server
或者
sudo systemctl stop mssql-server

2.重新配置mssql-server产品服务

[root@localhost ~]# /opt/mssql/bin/mssql-conf setup
Choose an edition of SQL Server:
  1) Evaluation (free, no production use rights, 180-day limit)
  2) Developer (free, no production use rights)
  3) Express (free)
  4) Web (PAID)
  5) Standard (PAID)
  6) Enterprise (PAID)
  7) Enterprise Core (PAID)
  8) I bought a license through a retail sales channel and have a product key to enter.

Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=852748&clcid=0x409

Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.

Enter your edition(1-8): 3
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=855862&clcid=0x409

The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409

Enter the SQL Server system administrator password: 
Confirm the SQL Server system administrator password: 
Configuring SQL Server...

The licensing PID was successfully processed. The new edition is [Express Edition].
ForceFlush is enabled for this instance. 
ForceFlush feature is enabled for log durability.
Setup has completed successfully. SQL Server is now starting.

说明选择edition的时候,我选择的是3,当时安装的时候安装的是(Express 免费版),大家根据自己部署的情况进行选择。选择完后,就是到了重置SA密码,然后输入2遍密码即可完成操作。设置完SA密码后,服务会自动启动不用我们管的。

3.检查mssql-server服务进程状态

[root@localhost ~]# systemctl status mssql-server
● mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2021-10-25 05:14:57 CST; 47min ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 5170 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ├─5170 /opt/mssql/bin/sqlservr
           └─5190 /opt/mssql/bin/sqlservr

Oct 25 05:15:01 localhost.localdomain sqlservr[5170]: 2021-10-25 05:15:01.84 spid18s     Server is listening on [ 'any' <ipv4> 1433].
Oct 25 05:15:01 localhost.localdomain sqlservr[5170]: 2021-10-25 05:15:01.84 spid18s     Dedicated administrator connection support was not started becaus...
Oct 25 05:15:01 localhost.localdomain sqlservr[5170]: 2021-10-25 05:15:01.86 spid18s     SQL Server is now ready for client connections. This is a...equired.
Oct 25 05:15:02 localhost.localdomain sqlservr[5170]: 2021-10-25 05:15:02.01 spid11s     Starting up database 'tempdb'.
Oct 25 05:15:02 localhost.localdomain sqlservr[5170]: 2021-10-25 05:15:02.18 spid21s     The Service Broker endpoint is in disabled or stopped state.
Oct 25 05:15:02 localhost.localdomain sqlservr[5170]: 2021-10-25 05:15:02.18 spid21s     The Database Mirroring endpoint is in disabled or stopped state.
Oct 25 05:15:02 localhost.localdomain sqlservr[5170]: 2021-10-25 05:15:02.20 spid21s     Service Broker manager has started.
Oct 25 05:15:02 localhost.localdomain sqlservr[5170]: 2021-10-25 05:15:02.20 spid6s      Recovery is complete. This is an informational message on...equired.
Oct 25 05:21:46 localhost.localdomain sqlservr[5170]: 2021-10-25 05:21:46.54 spid52      Attempting to load library 'xplog70.dll' into memory. Thi...equired.
Oct 25 05:21:46 localhost.localdomain sqlservr[5170]: 2021-10-25 05:21:46.57 spid52      Using 'xplog70.dll' version '2017.140.3411' to execute ex...equired.
Hint: Some lines were ellipsized, use -l to show in full.

5.命令行登陆sqlserver数据库

[root@localhost ~]# sqlcmd -S localhost -U SA -p
Password: 
1> select [name] from sys.databases
2> go
name                                                                                                                            
--------------------------------------------------------------------------------------------------------------------------------
master                                                                                                                          
tempdb                                                                                                                          
model                                                                                                                           
msdb                                                                                                                            

(4 rows affected)

Network packet size (bytes): 4096
1 xact[s]:
Clock Time (ms.): total         2  avg   2.0 (500.0 xacts per sec.)
1> 

 类似资料: