{"id":1493,"date":"2024-07-12T10:56:55","date_gmt":"2024-07-12T02:56:55","guid":{"rendered":"http:\/\/www.leyiwangyou.top\/?p=1493"},"modified":"2024-09-14T12:49:36","modified_gmt":"2024-09-14T04:49:36","slug":"docker-install-sql-server","status":"publish","type":"post","link":"http:\/\/www.leyiwangyou.top\/?p=1493","title":{"rendered":"Docker Install SQL Server"},"content":{"rendered":"<h1>Docker Install SQL Server<\/h1>\n<h2>Docker pull<\/h2>\n<p>first step pull image<a href=\"https:\/\/hub.docker.com\/r\/microsoft\/mssql-server\">: https:\/\/hub.docker.com\/r\/microsoft\/mssql-server<\/a><\/p>\n<pre><code class=\"language-bash\">docker pull mcr.microsoft.com\/mssql\/server<\/code><\/pre>\n<h2>Docker run<\/h2>\n<pre><code class=\"language-bash\">docker run -e \"ACCEPT_EULA=Y\" -e \"MSSQL_SA_PASSWORD=yourStrong(!)Password\" -e \"MSSQL_PID=Evaluation\" -p 1433:1433  --name mssql2022 -d mcr.microsoft.com\/mssql\/server<\/code><\/pre>\n<p><strong>Environment Variables<\/strong><br \/>\nYou can use environment variables to configure SQL Server on Linux Containers.<\/p>\n<p><em>ACCEPT_EULA<\/em> confirms your acceptance of the End-User Licensing Agreement.<\/p>\n<p><em>MSSQL_SA_PASSWORD<\/em> is the database system administrator (userid = &#8216;sa&#8217;) password used to connect to SQL Server once the container is running. Important note: This password needs to include at least 8 characters of at least three of these four categories: uppercase letters, lowercase letters, numbers and non-alphanumeric symbols.<\/p>\n<p><em>MSSQL_PID<\/em> is the Product ID (PID) or Edition that the container will run with. Acceptable values:<\/p>\n<ul>\n<li>Developer : This will run the container using the Developer Edition (this is the default if no -MSSQL_PID environment variable is supplied)<\/li>\n<li>Express : This will run the container using the Express Edition<\/li>\n<li>Standard : This will run the container using the Standard Edition<\/li>\n<li>Enterprise : This will run the container using the Enterprise Edition<\/li>\n<li>EnterpriseCore : This will run the container using the Enterprise Edition Core : This will run the container with the edition that is associated with the PID<\/li>\n<\/ul>\n<h2>Docker exec<\/h2>\n<pre><code class=\"language-bash\">docker exec -it mssql2022 \"bash\"<\/code><\/pre>\n<h2>use sqlcmd connect sql server<\/h2>\n<pre><code class=\"language-bash\">mssql@ecf27c316472:\/$ \/opt\/mssql-tools\/bin\/sqlcmd -S localhost -U SA -P yourPassword\n1&gt; select @@version\n2&gt; go\n\nMicrosoft SQL Server 2022 (RTM-CU13) (KB5036432) - 16.0.4125.3 (X64)\n        May  1 2024 15:05:56\n        Copyright (C) 2022 Microsoft Corporation\n        Developer Edition (64-bit) on Linux (Ubuntu 22.04.4 LTS) &lt;X64&gt;<\/code><\/pre>\n<h2>create new database<\/h2>\n<pre><code class=\"language-sql\">CREATE DATABASE TestDB;\n\nSELECT Name from sys.databases;\n\nGO<\/code><\/pre>\n<h2>create new table<\/h2>\n<pre><code class=\"language-sql\">USE TestDB;\n\nCREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT);\n\nINSERT INTO Inventory VALUES (1, 'banana', 150); \nINSERT INTO Inventory VALUES (2, 'orange', 154);\n\nGO<\/code><\/pre>\n<h2>query data<\/h2>\n<pre><code>1&gt; SELECT * FROM Inventory WHERE quantity &gt; 152;\n2&gt; Go\nid          name                                               quantity\n----------- -------------------------------------------------- -----------\n          2 orange                                                     154<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Docker Install SQL S<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[384],"tags":[383],"class_list":["post-1493","post","type-post","status-publish","format-standard","hentry","category-docker","tag-docker"],"_links":{"self":[{"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=\/wp\/v2\/posts\/1493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1493"}],"version-history":[{"count":6,"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=\/wp\/v2\/posts\/1493\/revisions"}],"predecessor-version":[{"id":1510,"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=\/wp\/v2\/posts\/1493\/revisions\/1510"}],"wp:attachment":[{"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1493"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.leyiwangyou.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}