At this time of writing, Microsoft SQL Server 2019 does not support Ubuntu 22.04. But if you are Ubuntu 22.04 user, there is another way to install SQL Server in your OS, by using Docker. In this tutorial, I will show you how to install SQL Server on Ubuntu 22.04 using Docker. SQL Server can be used to store spatial databases. It supports ArcGIS Pro, QGIS, and other GIS software. It’s a great spatial database that has been used by millions of users out there.
Steps to Install Microsoft SQL Server on Ubuntu 22.04
Step 1. Install Docker
I assume you have a Ubuntu 22.04 desktop or Server edition. First, we need to install Docker on Ubuntu 22.04. Open the Terminal or connect to the server via SSH and then use this command to prepare some basic stuff.
sudo apt update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
And then, these commands to add the Docker repository
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Now update Ubuntu
sudo apt update
Install Docker
Now use this command to install the Docker engine
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Now start Docker and verify the status
sudo service docker start
sudo service docker status
Make sure you get the following output
At this point, we have successfully installed Docker. Now we are ready to install Microsoft SQL Server on our Docker container.
Step 2. Install Microsoft SQL Server 2019 on Docker
First, we need to pull the SQL Server image.
sudo docker pull mcr.microsoft.com/mssql/server:2019-latest
Downloading SQL Server Docker Image
Now let’s create the Docker container
sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>" \
-p 1433:1433 --name sql1 --hostname sql1 \
-d \
mcr.microsoft.com/mssql/server:2019-latest
Don’t forget to change <YourStrong@Password> with your own password. Please read the password complexity requirements. For a complete guide and help with installing SQL Server in Docker, please visit this official page.
Check if the new Docker container is up and running
sudo docker ps -a
Output:
At this point, we have successfully installed Microsoft SQL Server 2019 on Ubuntu Docker.
Create a New Database
To create a new database in your SQL Server, you can use the sqlcmd but I will not explain it here. If you prefer the sqlcmd way, please read this article. In this section, I am going to create a new database using Azure Data Studio. It is a free GUI software to manage your SQL Server. It can be used to connect to multiple servers as well as create a new database.
Download and install Azure Data Studio and then create a new connection to the SQL Server we’ve just installed.
Click Create a connection and then enter the SQL Server details
Click Connect to start the connection. Now your SQL Server is ready to be used. To create a new database using Azure Data Studio, right-click on your server and click New Query.
And then type the following command in the query window. Don’t forget to change “test” with your actual database name.
CREATE DATABASE test;
GO
Click Run to execute the query. In a few moments, the new database should be ready.
Done.
Final Thoughts
We went through all the steps to install Microsoft SQL Server 2019 on Ubuntu 22.04 using Docker. It is a pretty long step but I think in the end, we have a good result. Thank you for reading this article and see you in the next articles. Stay safe.
How to Install SQL Server Docker on Apple Silicon Mac - GIS Tutorial
October 23, 2022[…] aren’t compatible yet. For example, Microsoft SQL Server. In the previous article, we learned how to install Microsoft SQL Server 2019 Docker on Ubuntu 22.04. But today we are going to install SQL Server on Ubuntu 22.04 ARM using Docker. Well, it is not the […]
Clarion Isige
October 26, 2022Hello, I installed Mssql using the procedure above. However, I have a problem running the server on Azure data studio.
What details should be input for the server, user name?
admin
October 26, 2022User name should be “sa” without quotes
ubuntu mssql server 설치 – NICE_BLOG
November 16, 2022[…] How to Install Microsoft SQL Server on Ubuntu 22.04 Using Docker […]
Sattick
November 17, 2022I am not able to determine the server. please help
abdel
December 10, 2022Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 – Could not open a connection to SQL Server: Could not open a connection to SQL Server)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnectionString connectionOptions, Boolean withFailover)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken, DbConnectionPool pool)
at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionFactory.c__DisplayClass48_0.b__0(Task`1 _)
at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
at System.Threading.Tasks.Task.c.b__272_0(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
— End of stack trace from previous location —
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
— End of stack trace from previous location —
at Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection.ReliableSqlConnection.c__DisplayClass30_0.<b__0>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.SqlTools.ManagedBatchParser\ReliableConnection\ReliableSqlConnection.cs:line 312
— End of stack trace from previous location —
at Microsoft.SqlTools.ServiceLayer.Connection.ConnectionService.TryOpenConnection(ConnectionInfo connectionInfo, ConnectParams connectionParams) in D:\a\_work\1\s\src\Microsoft.SqlTools.ServiceLayer\Connection\ConnectionService.cs:line 666
ClientConnectionId:00000000-0000-0000-0000-000000000000
Adesoji
January 12, 2023how do i get my server address like your 192.168.0.7
admin
January 12, 2023Execute the “ip addr” without quotes in ubuntu to see the ip
Address