{"id":3382,"date":"2022-09-27T15:32:01","date_gmt":"2022-04-20T22:48:37","guid":{"rendered":""},"modified":"2025-02-02T00:46:20","modified_gmt":"2025-02-01T23:46:20","slug":"comprehensive-guide-install-and-configure-microsoft-sql-server-on-linux","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/comprehensive-guide-install-and-configure-microsoft-sql-server-on-linux\/","title":{"rendered":"Comprehensive Guide: Install and Configure Microsoft SQL Server on Linux"},"content":{"rendered":"<p>\u00a0<\/p>\n<\/p>\n<h1>\u00a0<\/h1>\n<h2>1. Introduction<\/h2>\n<p>Microsoft SQL Server is a powerful relational database management system. This guide covers the installation, configuration, database creation, security settings, and backup automation on Linux.<\/p>\n<h2>2. System Requirements<\/h2>\n<ul>\n<li>Ubuntu 20.04 or later \/ CentOS 7 or later<\/li>\n<li>At least 2GB RAM and 10GB free disk space<\/li>\n<li>Administrator (sudo) access<\/li>\n<\/ul>\n<h2>3. Installing Microsoft SQL Server<\/h2>\n<h3>3.1 Adding the Microsoft Repository<\/h3>\n<pre>    sudo wget -qO- https:\/\/packages.microsoft.com\/keys\/microsoft.asc | sudo apt-key add -\r\n    sudo add-apt-repository \"$(wget -qO- https:\/\/packages.microsoft.com\/config\/ubuntu\/20.04\/mssql-server-2019.list)\"\r\n    sudo apt update\r\n    <\/pre>\n<h3>3.2 Installing SQL Server<\/h3>\n<pre>    sudo apt install -y mssql-server\r\n    sudo \/opt\/mssql\/bin\/mssql-conf setup\r\n    sudo systemctl enable --now mssql-server\r\n    <\/pre>\n<p>Follow the on-screen instructions to configure SQL Server settings.<\/p>\n<h2>4. Configuring SQL Server<\/h2>\n<h3>4.1 Installing SQL Server Command-Line Tools<\/h3>\n<pre>    sudo apt install -y mssql-tools unixodbc-dev\r\n    echo 'export PATH=\"$PATH:\/opt\/mssql-tools\/bin\"' &gt;&gt; ~\/.bashrc\r\n    source ~\/.bashrc\r\n    <\/pre>\n<h3>4.2 Connecting to SQL Server<\/h3>\n<pre>    sqlcmd -S localhost -U SA -P 'YourStrongPassword'\r\n    <\/pre>\n<h2>5. Creating and Managing Databases<\/h2>\n<pre>    CREATE DATABASE TestDB;\r\n    GO\r\n    USE TestDB;\r\n    CREATE TABLE Users (ID INT PRIMARY KEY, Name NVARCHAR(50));\r\n    GO\r\n    INSERT INTO Users (ID, Name) VALUES (1, 'Alice');\r\n    SELECT * FROM Users;\r\n    GO\r\n    <\/pre>\n<h2>6. Configuring Remote Access<\/h2>\n<pre>    sudo ufw allow 1433\/tcp\r\n    sudo systemctl restart mssql-server\r\n    <\/pre>\n<p>Ensure SQL Server is set to allow remote connections by modifying the configuration file.<\/p>\n<h2>7. Setting Up Automated Backups<\/h2>\n<h3>7.1 Creating a Backup Script<\/h3>\n<pre>    #!\/bin\/bash\r\n    TIMESTAMP=$(date +\"%Y-%m-%d_%H-%M-%S\")\r\n    BACKUP_DIR=\"\/var\/opt\/mssql\/backups\"\r\n    \/opt\/mssql-tools\/bin\/sqlcmd -S localhost -U SA -P 'YourStrongPassword' -Q \\\r\n    \"BACKUP DATABASE TestDB TO DISK = '$BACKUP_DIR\/TestDB_$TIMESTAMP.bak'\"\r\n    <\/pre>\n<h3>7.2 Automating Backups with Cron<\/h3>\n<pre>    crontab -e\r\n    0 2 * * * \/path\/to\/backup_script.sh\r\n    <\/pre>\n<p>This schedules a daily backup at 2 AM.<\/p>\n<h2>8. Conclusion<\/h2>\n<p>Following this guide, you should now have a fully operational Microsoft SQL Server on Linux, with remote access and automated backups configured.<\/p>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 1. Introduction Microsoft SQL Server is a powerful relational database management system. This guide covers the installation, configuration, database creation, security settings, and backup automation on\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-3382","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/3382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=3382"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/3382\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=3382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=3382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=3382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}