Olá,
É comum precisarmos resetar a senha do usuário "sa" no SQL Server caso tenhamos esquecido a mesma. No SQL Server do Linux temos um jeito muito fácil de realizar este procedimento.
Supondo eu eu tenha esquecido a senha do usuário "sa":
[root@linux ~]# sqlcmd -S localhost -U sa -Psenha
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'sa'..
Para definir uma nova senha, basta executarmos o procedimento set-sa-password conforme demonstrado a seguir.
[root@linux ~]# /opt/mssql/bin/mssql-conf set-sa-password
An instance of SQL Server is running. Please stop the SQL Server service
using the following command
sudo systemctl stop mssql-server
Para realizar tal procedimento, a instância do SQL Server deverá sofrer shutdown caso a mesma esteja no ar.
[root@linux ~]# systemctl stop mssql-server
[root@linux ~]# /opt/mssql/bin/mssql-conf set-sa-password
Enter the SQL Server system administrator password: *********
Confirm the SQL Server system administrator password: *********
Configuring SQL Server...
ForceFlush is enabled for this instance.
ForceFlush feature is enabled for log durability.
The system administrator password has been changed.
Please run 'sudo systemctl start mssql-server' to start SQL Server.
Pronto. Após a definição da nova senha, poderemos reiniciar o SQL Server.
[root@linux ~]# systemctl start mssql-server
[root@linux ~]# 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 Tue 2019-11-05 12:44:49 -03; 11s ago
Docs: https://docs.microsoft.com/en-us/sql/linux
Main PID: 3523 (sqlservr)
CGroup: /system.slice/mssql-server.service
|--3523 /opt/mssql/bin/sqlservr
|--3526 /opt/mssql/bin/sqlservr
Nov 5 12:44:59 linux.local.net sqlservr[3523]: 2019-11-05 12:44:59.70 Server InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
Nov 5 12:44:59 linux.local.net sqlservr[3523]: 2019-11-05 12:44:59.70 Server Implied authentication manager initialization failed. Implied authentication will be disabled.
Nov 5 12:44:59 linux.local.net sqlservr[3523]: 2019-11-05 12:44:59.75 Server Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2']. Allowed TLS ciphers are ['ECDHE-ECDS...CDHE-ECDSA-AES12
Nov 5 12:44:59 linux.local.net sqlservr[3523]: 2019-11-05 12:44:59.87 Server The maximum number of dedicated administrator connections for this instance is '1'
Nov 5 12:44:59 linux.local.net sqlservr[3523]: 2019-11-05 12:44:59.87 Server Node configuration: node 0: CPU mask: 0x0000000000000003:0 Active CPU mask: 0x0000000000000003:0. This message provides a description o...ion is required.
Nov 5 12:44:59 linux.local.net sqlservr[3523]: 2019-11-05 12:44:59.90 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational m...ion is required.
Nov 5 12:44:59 linux.local.net sqlservr[3523]: 2019-11-05 12:44:59.94 Server In-Memory OLTP initialized on lowend machine.
Nov 5 12:45:00 linux.local.net sqlservr[3523]: 2019-11-05 12:45:00.30 Server Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initial...ion is required.
Nov 5 12:45:00 linux.local.net sqlservr[3523]: ForceFlush is enabled for this instance.
Nov 5 12:45:00 linux.local.net sqlservr[3523]: 2019-11-05 12:45:00.33 Server Query Store settings initialized with enabled = 1,
Hint: Some lines were ellipsized, use -l to show in full.
Com a instância no ar, podemos testar novamente a conexão com a nova senha definida.
[root@linux ~]# sqlcmd -S localhost -U sa -Psenha
1> select @@version
2> GO
--------------------------------------------------------------------
Microsoft SQL Server 2017 (RTM-CU17) (KB4515579) - 14.0.3238.1 (X64)
Sep 13 2019 15:49:57
Copyright (C) 2017 Microsoft Corporation
Enterprise Edition (64-bit) on Linux (CentOS Linux 7 (Core))
(1 rows affected)
Nenhum comentário:
Postar um comentário