datablogs

SQL Server on Linux in AWS EC2 – Installation, Password Configuration, Cost Benefits, and Limitations

Introduction

As part of a learning and testing initiative, I explored deploying Microsoft SQL Server 2022 on Ubuntu Linux in AWS EC2. The goal was to understand the installation process, validate SQL Server functionality on Linux, and evaluate the potential cost benefits compared to traditional Windows-based deployments.

The setup was completed successfully, and SQL Server 2022 was up and running on Ubuntu 22.04 with remote connectivity enabled.


Why SQL Server on Linux?

Microsoft introduced SQL Server on Linux to provide customers with more deployment flexibility while maintaining the same core database engine capabilities.

Key advantages include:

  • Lower infrastructure costs
  • No Windows Server licensing requirement
  • Better resource utilization
  • Cloud-friendly deployment model
  • Suitable for development, testing, and production workloads

Environment Details

Component

Value

Cloud Platform

AWS EC2

Operating System

Ubuntu 22.04 LTS

Database Version

SQL Server 2022 CU18

Edition

Web Edition

Connectivity

TCP Port 1433


Step 1 – Launch AWS EC2 Instance

Provision an Ubuntu 22.04 EC2 instance with:

  • 2 vCPU or higher
  • 8 GB RAM or higher
  • Sufficient EBS Storage
  • SSH Access Enabled

After instance creation, connect using SSH.


Step 2 – Install SQL Server 2022

Update the operating system:

sudo apt update

sudo apt upgrade -y


Add Microsoft package repository:

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list)"


Install SQL Server:

sudo apt update

sudo apt install -y mssql-server


Configure SQL Server:

sudo /opt/mssql/bin/mssql-conf setup


During setup:

  • Accept License Agreement
  • Select SQL Server Edition
  • Configure SA Password

Step 3 – Start and Verify SQL Server Service

Enable and start the SQL Server service:

sudo systemctl enable mssql-server

sudo systemctl start mssql-server


Check service status:

sudo systemctl status mssql-server


Validation

The service should display:

Active: active (running)


Step 4 – Install SQL Server Command Line Tools

Install SQLCMD utilities:

sudo apt-get install mssql-tools unixodbc-dev -y


Update the PATH:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

source ~/.bashrc


Verify installation:

sqlcmd -?


Step 5 – Validate SQL Server Installation

Connect to SQL Server:

sqlcmd -S localhost -U SA -P 'YourPassword'


Check version:

SELECT @@VERSION;

GO


Expected output:

Microsoft SQL Server 2022 (RTM-CU18)

Web Edition

Linux (Ubuntu 22.04)


Step 6 – Reset SA Password

If the SA password is forgotten or needs to be changed, SQL Server on Linux provides a simple method to reset it.

Stop SQL Server:

sudo systemctl stop mssql-server


Reset the SA password:

sudo /opt/mssql/bin/mssql-conf set-sa-password


Provide a password that meets complexity requirements:

  • Minimum 8 characters
  • Uppercase letter
  • Lowercase letter
  • Number
  • Special character

Start SQL Server again:

sudo systemctl start mssql-server


Verify connectivity:

sqlcmd -S localhost -U SA -P 'NewPassword'



Step 7 – Enable Remote Connectivity

Allow SQL Server port:

sudo ufw allow 1433/tcp


Verify listener:

sudo ss -tlnp | grep 1433


Expected output:

0.0.0.0:1433


In AWS, also update the Security Group to allow inbound access on TCP port 1433 from trusted networks.


Cost Benefits

One of the primary reasons organizations consider SQL Server on Linux is cost optimization.

Cost Comparison

Environment

Monthly Cost

SQL Server on Windows

$910

SQL Server on Linux

$455

Savings Achieved

Metric

Value

Monthly Savings

$455

Annual Savings

$5,460

Benefits

  • Reduced infrastructure costs
  • Elimination of Windows Server licensing
  • Lower operating system overhead
  • Better resource efficiency
  • Improved cloud cost optimization

For organizations running multiple SQL Server environments (Development, Testing, UAT, Production), the savings can be substantial.


Limitations and Considerations

While SQL Server on Linux is mature and production-ready, there are a few considerations:

Learning Curve

Administrators familiar only with Windows may need to become comfortable with Linux administration and command-line operations.

Windows-Specific Features

Some Windows-integrated features and tools may not be available or may require alternative approaches.

Third-Party Tool Compatibility

Certain third-party monitoring and administration tools may have limited support for Linux deployments.

Active Directory Integration

Additional configuration may be required when integrating with enterprise authentication services.

Operational Skills

Basic Linux administration knowledge is recommended for troubleshooting and maintenance activities.


Conclusion

Deploying SQL Server 2022 on Ubuntu Linux in AWS proved to be a straightforward and effective exercise. The installation process was simple, password management was easy to configure, and the database engine performed exactly as expected.

Most importantly, the deployment demonstrated a potential cost saving of approximately $455 per month ($5,460 annually) compared to a similar Windows-based setup.

For development, testing, learning environments, and even many production workloads, SQL Server on Linux offers a compelling combination of performance, flexibility, and cost efficiency.

0 Comments