You can perform an unattended installation by following these steps:
Add the repository and install SQL Server.
When you run Mssql-conf Setup, set the environment variables and use the-n option (without prompting).
#!/bin/bash -e# use the following variables to control your install:# password for the sa user (required) mssql_sa_password= ' <YourStrong! Passw0rd> ' # product id of the version of sql server you ' re installing# must be evaluation, developer, express, web, standard, enterprise, or your 25 digit product key# Defaults to Developermssql_pid= ' Evaluation ' # install sql server agent (recommended) Sql_install_ Agent= ' y ' # install sql server full text search (optional) # SQL_INSTALL _fulltext= ' Y ' # create an additional user with sysadmin privileges ( Optional) # sql_install_user= ' <Username> ' # sql_install_user_password= ' <yourstrong! Passw0rd> ' if [ -z $MSSQL _Sa_password ]then echo environment variable mssql_sa_password must be set for unattended install exit 1fiecho Adding Microsoft repositories...sudo curl -o /etc/yum.repos.d/mssql-server.repo https:// packages.microsoft.com/config/rhel/7/mssql-server-2017.reposudo curl -o /etc/yum.repos.d/ msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repoecho installing sql Server...sudo yum install -y mssql-serverecho running mssql-conf setup ... sudo mssql_sa_password= $MSSQL _sa_password mssql_pid= $MSSQL _pid /opt/mssql/bin/mssql-conf -n setup accept-eulaecho installing mssql-tools and unixodbc developer...sudo accept_eula=y yum Install -y mssql-tools unixodbc-devel#&nbsP Add sql server tools to the path by default:echo adding sql server tools to your path...echo path= "$PATH:/opt/mssql-tools/bin" > > ~/.bash_profileecho ' export path= ' $PATH:/opt/mssql-tools/bin "' >> ~/. bashrc# optional sql server agent installation:if [ ! -z $SQL _ Install_agent ]then echo installing sql server agent... sudo yum install -y mssql-server-agentfi# Optional SQL Server Full text search installation:if [ ! -z $SQL _install_fulltext ]then echo Installing SQL Server Full-Text Search... Sudo yum install -y mssql-server-ftsfi# configure firewall to allow tcp port 1433:echo configuring firewall to allow traffic on port 1433...sudo firewall-cmd --zone=public --add-port=1433/tcp --permanentsudo firewall-cmd --reload# example of setting post-installation configuration options# set trace flags 1204 and 1222 for deadlock tracing: #echo setting trace flags. #sudo /opt/mssql/bin/mssql-conf traceflag 1204 1222 on# restart sql server after making configuration changes:echo restarting sql server...sudo systemctl restart mssql-server# connect to server and get the version:counter=1errstatus=1while [ $counter -le 5 ] && [ $errstatus = 1 ]do echo Waiting for SQL Server to start...&nbSp; sleep 5s /opt/mssql-tools/bin/sqlcmd -s localhost -U SA -P $MSSQL _sa_password -Q "select @ @VERSION" 2>/dev/null errstatus=$? (( counter++)) done# display error if connection failed:if [ $errstatus = 1 ]then echo cannot connect to sql server, installation aborted exit $ERRSTATUSFI # optional new user creation:if [ ! -z $SQL _install_user ] && [ ! -z $SQL _install_user_ password ]then echo creating user $SQL _install_user /opt/mssql-tools /bin/sqlcmd -s localhost -u sa -P $MSsql_sa_password -q "create login [$SQL _install_user] with password=n ' $SQL _install_user_password ', default_database=[master], check_expiration=on, check_policy=on; alter server role [sysadmin] add member [$SQL _install_user ] "fiecho done!
Run the unattended setup script:
1. Save the above script as install_sql.sh.
2. Specify Mssql_sa_password, Mssql_pid, and other variables that you want to modify.
3. Modify the script to executable.
chmod +x install_sql.sh
4. Run the script.
./install_sql.sh
unattended installation of SQL Server 2017 on Linux