MS SQL is a relational database system by Microsoft that was open-sourced in 2016. In this article, I’ll take you through the steps to install MS SQL server 2019 on Ubuntu 18.04 Linux system.
Below are the minimum system requirements to run MS SQL on Ubuntu 20.04/18.04/16.04 server:
- Minimum memory of 2 GB
- CPU processor with a minimum speed of 1.4 GHz. But the recommended is >= 2 GHz
- SQL Server requires a minimum of 10 GB of available hard-disk space
The is following server specifications that we used for SQL Server 2019 :
A. Step-step to Install SQL Server 2019 :
- Import the public repository GPG keys:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
2. Register the Microsoft SQL Server Ubuntu repository for SQL Server 2019
sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"
3. Run the following commands to install SQL Server:
sudo apt-get update
sudo apt-get install -y mssql-server
4. After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.
sudo /opt/mssql/bin/mssql-conf setup
Because we have a SQL Server Licence, so i choose option setup number 8, then entering the licence product key
5. Once the configuration is done, verify that the service is running
systemctl status mssql-server --no-pager
If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewall.
At this point, SQL Server 2019 is running on your Ubuntu machine and is ready to use!
B. Install the SQL Server command-line tools Server 2019 :
To create a database, you need to connect with a tool that can run Transact-SQL statements on the SQL Server. The following steps install the SQL Server command-line tools: sqlcmd and bcp.
Use the following steps to install the mssql-tools on Ubuntu.
1.Import the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
2. Register the Microsoft Ubuntu repository.
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
/18.04 = depending of your ubuntu version.
3. Update the sources list and run the installation command with the unixODBC developer package. For more information, see Install the Microsoft ODBC driver for SQL Server (Linux).
sudo apt-get update sudo ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd sudo ACCEPT_EULA=Y apt-get install mssql-tools echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
# optional: for unixODBC development headers sudo apt-get install unixodbc-dev
C. Connect locally use SQLCMD
1.Run sqlcmd with parameters for your SQL Server name (-S), the user name (-U), and the password (local).
sqlcmd -S localhost -U SA -P '<yourpasswor>'
2. If Succeed to login, the prompt will be like this below
Then you can try all the SQL Command then, like Create Database, Query, Delete data, or database and so on
D. Connect remotly Using SQL Management Studio
If you plan to connect remotely, you might also need to open the SQL Server TCP port (default 1433) on your firewal
E. Reset SQL Server SA Password (If needed)
1. Connect SQL Server using command-line tool with the existing password to make sure that your current password is working. You will skip this step if you don’t know the password.
sqlcmd -S <SQLInstanceName>-U <UserName> -P <Password>
2. To change the “sa” password, first stop SQL Server service on Linux:
sudo systemctl stop mssql-server sudo systemctl status mssql-server
3. Reset the “sa” password with new one
4. Start and verify the status of SQL Server Service:
sudo systemctl start mssql-server sudo systemctl status mssql-server
5. Wola!. You are done to change the password.
Infinys Cloud System https://isi.co.id/