{"id":12685,"date":"2025-01-21T07:09:41","date_gmt":"2025-01-21T07:09:41","guid":{"rendered":"https:\/\/myprojects.advchaweb.com\/?p=12685"},"modified":"2025-01-21T09:54:28","modified_gmt":"2025-01-21T09:54:28","slug":"install-microsoft-sql-server-2022-on-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/myprojects.advchaweb.com\/index.php\/2025\/01\/21\/install-microsoft-sql-server-2022-on-ubuntu-22-04\/","title":{"rendered":"Install Microsoft SQL Server 2022 On Ubuntu 22.04"},"content":{"rendered":"<p>Ref: https:\/\/learn.microsoft.com\/en-us\/sql\/linux\/quickstart-install-connect-ubuntu?view=sql-server-ver16&amp;tabs=ubuntu2204<\/p>\n<p>1. Update and upgrade the packages on ubuntu 22.04<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>sudo apt update\r\nsudo apt upgrade -y<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>2. Download the public key, convert from ASCII to GPG format, and write it to the required location:<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>curl -fsSL https:\/\/packages.microsoft.com\/keys\/microsoft.asc | sudo gpg --dearmor -o \/usr\/share\/keyrings\/microsoft-prod.gpg<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>3. Manually download and register the SQL Server Ubuntu repository:<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>curl -fsSL https:\/\/packages.microsoft.com\/config\/ubuntu\/22.04\/mssql-server-2022.list | sudo tee \/etc\/apt\/sources.list.d\/mssql-server-2022.list<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>4. Run the following commands to install SQL Server:<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>sudo apt-get update\r\nsudo apt-get install -y mssql-server\r\n...\r\nSetting up libc++abi1-14:amd64 (1:14.0.0-1ubuntu1.1) ...\r\nSetting up libc++1-14:amd64 (1:14.0.0-1ubuntu1.1) ...\r\nSetting up libc++1:amd64 (1:14.0-55~exp2) ...\r\nSetting up mssql-server (16.0.4175.1-3) ...\r\n\r\n+--------------------------------------------------------------+\r\nPlease run 'sudo \/opt\/mssql\/bin\/mssql-conf setup'\r\nto complete the setup of Microsoft SQL Server\r\n+--------------------------------------------------------------+\r\n\r\nProcessing triggers for man-db (2.10.2-1) ...\r\nProcessing triggers for libc-bin (2.35-0ubuntu3.8) ...\r\n<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>5. After the package installation finishes, run\u00a0<code>mssql-conf setup<\/code>\u00a0and follow the prompts to set the\u00a0<code>sa<\/code>\u00a0password and choose your edition.<br \/>\nJust choose &#8216;Developer&#8217; version. type 2. My local <code>sa<\/code> password is {my-nick-name-first-uppercase}@123<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>satria@teddy:~$ sudo \/opt\/mssql\/bin\/mssql-conf setup\r\nChoose an edition of SQL Server:\r\n  1) Evaluation (free, no production use rights, 180-day limit)\r\n  2) Developer (free, no production use rights)\r\n  3) Express (free)\r\n  4) Web (PAID)\r\n  5) Standard (PAID)\r\n  6) Enterprise (PAID) - CPU core utilization restricted to 20 physical\/40 hyperthreaded\r\n  7) Enterprise Core (PAID) - CPU core utilization up to Operating System Maximum\r\n  8) I bought a license through a retail sales channel and have a product key to enter.\r\n  9) Standard (Billed through Azure) - Use pay-as-you-go billing through Azure.\r\n 10) Enterprise Core (Billed through Azure) - Use pay-as-you-go billing through Azure.\r\n\r\nDetails about editions can be found at\r\nhttps:\/\/go.microsoft.com\/fwlink\/?LinkId=2109348&clcid=0x409\r\n\r\nUse of PAID editions of this software requires separate licensing through a\r\nMicrosoft Volume Licensing program.\r\nBy choosing a PAID edition, you are verifying that you have the appropriate\r\nnumber of licenses in place to install and run this software.\r\nBy choosing an edition billed Pay-As-You-Go through Azure, you are verifying \r\nthat the server and SQL Server will be connected to Azure by installing the \r\nmanagement agent and Azure extension for SQL Server.\r\n\r\nEnter your edition(1-10): 2\r\nThe license terms for this product can be found in\r\n\/usr\/share\/doc\/mssql-server or downloaded from: https:\/\/aka.ms\/useterms\r\n\r\nThe privacy statement can be viewed at:\r\nhttps:\/\/go.microsoft.com\/fwlink\/?LinkId=853010&clcid=0x409\r\n\r\nDo you accept the license terms? [Yes\/No]:yes\r\n\r\nEnter the SQL Server system administrator password: \r\nConfirm the SQL Server system administrator password: \r\nConfiguring SQL Server...\r\n\r\nForceFlush is enabled for this instance. \r\nForceFlush feature is enabled for log durability.\r\nCreated symlink \/etc\/systemd\/system\/multi-user.target.wants\/mssql-server.service \u2192 \/lib\/systemd\/system\/mssql-server.service.\r\nSetup has completed successfully. SQL Server is now starting.<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>6. Once the configuration is done, verify that the service is running:<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>systemctl status mssql-server --no-pager<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>Install the SQL Server command-line tools (sqlcmd)<\/p>\n<p>1. Import the public repository GPG keys.<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>curl https:\/\/packages.microsoft.com\/keys\/microsoft.asc | sudo tee \/etc\/apt\/trusted.gpg.d\/microsoft.asc<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>2. Register the Microsoft Ubuntu repository. For Ubuntu 22.04, use the following command:<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>curl https:\/\/packages.microsoft.com\/config\/ubuntu\/22.04\/prod.list | sudo tee \/etc\/apt\/sources.list.d\/mssql-release.list<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>3. Update the sources list and run the installation command with the unixODBC developer package.<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>sudo apt-get update\r\nsudo apt-get install mssql-tools18 unixodbc-dev<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>To update to the latest version of\u00a0<strong>mssql-tools<\/strong>, run the following commands:<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>sudo apt-get update  \r\nsudo apt-get install mssql-tools18<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>4. Add\u00a0<code>\/opt\/mssql-tools18\/bin\/<\/code>\u00a0to your\u00a0<code>PATH<\/code>\u00a0environment variable in a bash shell.<\/p>\n<p>To make\u00a0<strong>sqlcmd<\/strong>\u00a0and\u00a0<strong>bcp<\/strong>\u00a0accessible from the bash shell for login sessions, modify your\u00a0<code>PATH<\/code>\u00a0in the\u00a0<code>~\/.bash_profile<\/code>\u00a0file with the following command:<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>echo 'export PATH=\"$PATH:\/opt\/mssql-tools18\/bin\"' &gt;&gt; ~\/.bash_profile\r\nsource ~\/.bash_profile<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>5. Test sqlcmd with &#8216;sqlcmd -?&#8217;<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>satria@teddy:~$ sqlcmd -?\r\nMicrosoft (R) SQL Server Command Line Tool\r\nVersion 18.4.0001.1 Linux\r\nCopyright (C) 2017 Microsoft Corporation. All rights reserved.\r\n\r\nusage: sqlcmd            [-U login id]          [-P password]\r\n  [-S server or Dsn if -D is provided] \r\n  [-H hostname]          [-E trusted connection]\r\n  ...\r\n  [-G use Microsoft Entra ID for authentication]\r\n  [-? show syntax summary]<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>Connect locally. I tried to use : sqlcmd -S localhost -U sa -P your_password<br \/>\nbut it showed up this error<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>satria@teddy:~$ sqlcmd -S localhost -U sa -P your_password\r\nSqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : SSL Provider: [error:0A000086:SSL routines::certificate verify failed:self-signed certificate].\r\nSqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Client unable to establish connection. For solutions related to encryption errors, see https:\/\/go.microsoft.com\/fwlink\/?linkid=2226722.<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>it turned out I need to add -C parameter at the end like this<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>satria@teddy:~$ sqlcmd -S localhost -U sa -P Teddy@123 -C\r\n1&gt; SELECT Name from sys.databases;\r\n2&gt; GO\r\nName                                                                                                                            \r\n--------------------------------------------------------------------------------------------------------------------------------\r\nmaster                                                                                                                          \r\ntempdb                                                                                                                          \r\nmodel                                                                                                                           \r\nmsdb                                                                                                                            \r\n\r\n(4 rows affected)\r\n1&gt; quit<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>Create a new database<\/p>\n<p>For example create a new database TestDB from sqlcmd<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>1&gt; CREATE DATABASE TestDB;\r\n2&gt; GO<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>Create a new table dbo.Inventory and Insert data<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>1&gt; USE TestDB;\r\n2&gt; GO\r\n1&gt; CREATE TABLE dbo.Inventory\r\n2&gt; (\r\n3&gt; id INT,\r\n4&gt; name NVARCHAR (50),\r\n5&gt; quantity INT,\r\n6&gt; PRIMARY KEY (id)\r\n7&gt; );\r\n8&gt; GO\r\n1&gt; INSERT INTO dbo.Inventory VALUES (1, 'banana', 150);\r\n2&gt; GO\r\n\r\n(1 rows affected)\r\n1&gt; INSERT INTO dbo.Inventory VALUES (2, 'orange', 154);\r\n2&gt; GO\r\n\r\n(1 rows affected)\r\n1&gt; SELECT * FROM dbo.Inventory;\r\n2&gt; GO\r\nid          name                                               quantity   \r\n----------- -------------------------------------------------- -----------\r\n          1 banana                                                     150\r\n          2 orange                                                     154\r\n\r\n(2 rows affected)\r\n1&gt; SELECT * FROM dbo.Inventory;\r\n2&gt; GO\r\nid          name                                               quantity   \r\n----------- -------------------------------------------------- -----------\r\n          1 banana                                                     150\r\n          2 orange                                                     154\r\n\r\n(2 rows affected)\r\n1&gt; quit<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>Install DBeaver (https:\/\/dbeaver.io\/)<br \/>\nThis is Database GUI for many databases including MS SQL Server<\/p>\n<p>Download it https:\/\/dbeaver.io\/download\/<br \/>\nI used Ubuntu PPA<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>sudo add-apt-repository ppa:serge-rider\/dbeaver-ce\r\nsudo apt-get update\r\nsudo apt-get install dbeaver-ce<\/pre>\n<p>[\/codesyntax]<\/p>\n<p>Open DBeaver CE and select to the MS SQL Server<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12693\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-connect.png\" alt=\"\" width=\"1429\" height=\"818\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-connect.png 1429w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-connect-300x172.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-connect-1024x586.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-connect-768x440.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-connect-1200x687.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>Connect to the MS SQL Server but it needs to use JDBC driver. Install it directly from the DBeaver<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12694\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-sql-server.png\" alt=\"\" width=\"1435\" height=\"808\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-sql-server.png 1435w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-sql-server-300x169.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-sql-server-1024x577.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-sql-server-768x432.png 768w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-sql-server-1200x676.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>If everything is okay, it&#8217;ll look like this<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-12695\" src=\"http:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-table.png\" alt=\"\" width=\"1156\" height=\"604\" srcset=\"https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-table.png 1156w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-table-300x157.png 300w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-table-1024x535.png 1024w, https:\/\/myprojects.advchaweb.com\/wp-content\/uploads\/2025\/01\/dbeaver-table-768x401.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>on the DBeaver GUI you can add a new row. for example add a new row<br \/>\nID: 3<br \/>\nName: Apple<br \/>\nQuantity: 158<br \/>\nThen save<\/p>\n<p>on the sqlcmd should reflect the changes<br \/>\n[codesyntax lang=&#8221;bash&#8221;]<\/p>\n<pre>1&gt; USE TestDB;\r\n2&gt; GO\r\nChanged database context to 'TestDB'.\r\n1&gt; SELECT * FROM dbo.Inventory;\r\n2&gt; GO\r\nid          name                                               quantity   \r\n----------- -------------------------------------------------- -----------\r\n          1 banana                                                     150\r\n          2 orange                                                     154\r\n          3 Apple                                                      158\r\n\r\n(3 rows affected)<\/pre>\n<p>[\/codesyntax]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ref: https:\/\/learn.microsoft.com\/en-us\/sql\/linux\/quickstart-install-connect-ubuntu?view=sql-server-ver16&amp;tabs=ubuntu2204 1. Update and upgrade the packages on ubuntu 22.04 [codesyntax lang=&#8221;bash&#8221;] sudo apt update sudo apt upgrade -y [\/codesyntax] 2. Download the public key, convert from ASCII to GPG format, and write it to the required location: [codesyntax lang=&#8221;bash&#8221;] curl -fsSL https:\/\/packages.microsoft.com\/keys\/microsoft.asc | sudo gpg &#8211;dearmor -o \/usr\/share\/keyrings\/microsoft-prod.gpg [\/codesyntax] 3. Manually download and &hellip; <a href=\"https:\/\/myprojects.advchaweb.com\/index.php\/2025\/01\/21\/install-microsoft-sql-server-2022-on-ubuntu-22-04\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install Microsoft SQL Server 2022 On Ubuntu 22.04&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[103,17,132],"tags":[],"class_list":["post-12685","post","type-post","status-publish","format-standard","hentry","category-ms-sql-server","category-ubuntu","category-ubuntu-22-04"],"_links":{"self":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/12685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/comments?post=12685"}],"version-history":[{"count":8,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/12685\/revisions"}],"predecessor-version":[{"id":12696,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/posts\/12685\/revisions\/12696"}],"wp:attachment":[{"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/media?parent=12685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/categories?post=12685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myprojects.advchaweb.com\/index.php\/wp-json\/wp\/v2\/tags?post=12685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}