Microsoft SQL or MS SQL is a relational database management system developed by Microsoft. SQL Server is not becoming open source, but will now run on open-source Linux systems. If you have applications that require MS SQL, you may be able to install and run them in a Linux environment. Before you can install MS SQL, you must have an Ubuntu 16.04, 18.04, or 20.04 machine with at least 2 GB of memory. After installing MS SQL, you then connect with sqlcmd to create your first database and run queries. If you’re a student or new user looking for a Linux system to start with, the easiest place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners and folks looking for easier Linux distribution to use. To get started with installing MS SQL on Ubuntu, follow the steps below:
Install MS SQL
To install MS SQL in Ubuntu, first import the public repository GPG keys to sign and trust packages from the repository. To do that, run the commands below. After installing the key, continue below to create a repository file to download SQL packages.
Add MS SQL Server Repository
Now that the repository key is installed, run the commands below to add MS SQL 2019 repository to Ubuntu. The following commands for SQL Server 2019 point to the Ubuntu 20.04 repository. If you are using Ubuntu 20.04 or 18.04, change the path below to /ubuntu/20.04/ instead of /ubuntu/18.04/. For Ubuntu 20.04, run the commands below: For Ubuntu 18.04, run the commands below:
Install MS SQL
After registering the repository to Ubuntu, run the commands below to update and install MS SQL on Ubuntu. Completion message: After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password, and choose your edition. That will prompt you to create the SA password. Once you’re done, you can verify MS SQL service is running by running the commands below: You should get similar lines as shown below: At this point, SQL Server 2019 is running on your Ubuntu machine and is ready to use! If you’re connecting remotely or allowing external applications to connect, you will want to open the firewall ports to allow traffic to the server. That should do it!
Install Additional Tools
To create databases, you need to connect with a tool that can run Transact-SQL statements on the SQL Server. Run the commands below to import the GPG keys for the tools repository. That adds the repository to Ubuntu. Ubuntu 18.04: After that, update the install support tools to connect to and manage MS SQL. To update to the latest version of mssql-tools run the following commands: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell. Now you can run sqlcmd to connect locally to the server name localhost. The username is SA and the password is the one you provided for the SA account during setup. If successful, you should get a command prompt: 1>. You should now be connected to the MS SQL console. Conclusion: This post showed you how to install MS SQL on Ubuntu 20.04 | 18.04. If you find any error above, please use the comment form below to report.