Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Configure SQL Server settings using environment variables on Linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

You can configure SQL Server 2017 on Linux with different environment variables. These variables are used in two scenarios:

Use the mssql-conf setup command to configure initialization settings.

Configure SQL Server in a new Docker container.

Environment variable

Environment variable

Description

ACCEPT_EULA

Accept the SQL Server license agreement when set to any value (for example, "Y").

MSSQL_SA_PASSWORD

Configure the SA user password.

MSSQL_PID

Set the SQL Server version or product key. Possible values include:

Evaluation

Developer

Express

Web

Standard

Enterprise edition

Product key

If you specify a product key, it must be in the format #-#, where # is a number or letter.

MSSQL_LCID

Sets the language ID to be used for SQL Server. For example, 1036 is French.

MSSQL_COLLATION

Sets the default collation for SQL Server. This overrides the default mapping of the collation language id (LCID).

MSSQL_MEMORY_LIMIT_MB

Sets the maximum length of memory (in mb) that SQL Server can use. By default, it is 80% of the total physical memory.

MSSQL_TCP_PORT

Configure the TCP port that SQL Server uses to listen on (default is 1433).

MSSQL_IP_ADDRESS

Set the IP address. Currently, the IP address must be IPv4 style (0.0.0.0).

MSSQL_BACKUP_DIR

Sets the default backup directory location.

MSSQL_DATA_DIR

Change the directory where the new SQL Server database data file (.mdf) was created.

MSSQL_LOG_DIR

Change the directory in which the new SQL Server database log (.ldf) file is created.

MSSQL_DUMP_DIR

Change the default directory where SQL Server stores memory dumps and other troubleshooting files.

MSSQL_ENABLE_HADR

Enable availability groups. For example, "1" is enabled and "0" is disabled

MSSQL_AGENT_ENABLED

Enable the SQL Server proxy. For example, 'true'' and 'false' are enabled and disabled. Proxies are disabled by default.

MSSQL_MASTER_DATA_FILE

Sets the location of the master database data file.

MSSQL_MASTER_LOG_FILE

Sets the location of the master database log file.

MSSQL_ERROR_LOG_FILE

Sets the location of the error log file.

Example: initial setup

This example will run mssql-conf setup with the configured environment variables. Specify the following environment variables:

ACCEPT_EULA accepts the end user license agreement.

MSSSQL_PID specifies that the developer version of SQL Server is licensed for use in a non-production environment.

MSSQL_SA_PASSWORD sets a strong password.

MSSQL_TCP_PORT sets the TCP port on which SQL Server learns to listen in 1234.

Sudo ACCEPT_EULA='Y' MSSQL_PID='Developer' MSSQL_SA_PASSWORD='' MSSQL_TCP_PORT=1234 / opt/mssql/bin/mssql-conf setup

Example: Docker

This sample docker command uses the following environment variables to create a new SQL Server 2017 container:

ACCEPT_EULA accepts the end user license agreement.

MSSSQL_PID specifies that the developer version of SQL Server is licensed for use in a non-production environment.

MSSQL_SA_PASSWORD sets a strong password.

MSSQL_TCP_PORT sets the TCP port on which SQL Server learns to listen in 1234. This means that instead of mapping port 1433 to the host port (the default), you must map the custom TCP port to the-p 1234gh1234 command in this example.

If you are running Docker on Linux/macOS, use the following syntax in single quotation marks:

Docker run-e ACCEPT_EULA=Y-e MSSQL_PID='Developer'-e MSSQL_SA_PASSWORD=''-e MSSQL_TCP_PORT=1234-p 1234purl 1234-d microsoft/mssql-server-linux:2017-latest

If you are running Docker on Windows, use the following syntax in double quotes:

Docker run-e ACCEPT_EULA=Y-e MSSQL_PID= "Developer"-e MSSQL_SA_PASSWORD= ""-e MSSQL_TCP_PORT=1234-p 1234 purl 1234-d microsoft/mssql-server-linux:2017-latest

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 291

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report