{"id":394,"date":"2021-08-02T05:29:01","date_gmt":"2021-08-02T05:29:01","guid":{"rendered":"https:\/\/leonsworkshop.com\/?p=394"},"modified":"2021-08-20T03:11:27","modified_gmt":"2021-08-20T03:11:27","slug":"sql-create-a-local-sql-server-on-your-macbook","status":"publish","type":"post","link":"https:\/\/leonsworkshop.com\/?p=394","title":{"rendered":"[SQL] Create a local SQL Server on your Macbook"},"content":{"rendered":"\n<p>This post is more like a note for myself about how I set up a local SQL server on the MacBook. If you happened to have the same need, and the steps are not detailed enough, please leave a comment or shoot me an email. Glad to help.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>1.Environment Setup<\/strong><\/p>\n\n\n\n<p>a. Register a Docker Account and Install Docker to your MacBook<\/p>\n\n\n\n<p><a href=\"https:\/\/www.docker.com\/\">Docker <img loading=\"lazy\" decoding=\"async\" width=\"15\" height=\"14\" class=\"wp-image-395\" style=\"width: 15px;\" src=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/pngfind.com-circle-icon-png-2553250.png\" alt=\"\" srcset=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/pngfind.com-circle-icon-png-2553250.png 4320w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/pngfind.com-circle-icon-png-2553250-300x286.png 300w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/pngfind.com-circle-icon-png-2553250-1024x976.png 1024w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/pngfind.com-circle-icon-png-2553250-150x150.png 150w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/pngfind.com-circle-icon-png-2553250-768x732.png 768w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/pngfind.com-circle-icon-png-2553250-1536x1464.png 1536w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/pngfind.com-circle-icon-png-2553250-2048x1952.png 2048w\" sizes=\"auto, (max-width: 15px) 100vw, 15px\" \/><\/a> will be the critical tool we need. Register a Docker account at: https:\/\/www.docker.com\/, a free account will be sufficient. <\/p>\n\n\n\n<p>b. Download &amp; Install Docker to your Macbook<\/p>\n\n\n\n<p>Download the latest version of Docker at the following location: <a rel=\"noreferrer noopener\" href=\"https:\/\/store.docker.com\/editions\/community\/docker-ce-desktop-mac\" target=\"_blank\">ttps:\/\/store.docker.com\/editions\/community\/docker-ce-desktop-mac<\/a>, and install it on your MacBook. Please make sure you grant it the proper system access it requests. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>2. Run Terminal<\/strong><\/p>\n\n\n\n<p>Once Docker has been successfully installed, that will be all we need from the Docker app for now. Open <strong>Terminal<\/strong> on your MacBook. <\/p>\n\n\n\n<p>a. Install Microsoft SQL Server Docker Container<\/p>\n\n\n\n<p>In your Terminal console, run the following command to install the Microsoft SQL Server 2019 Docker container to your laptop.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo docker pull mcr.microsoft.com\/mssql\/server:2019-latest<\/code><\/pre>\n\n\n\n<p>The <strong>Terminal<\/strong> will request you enter your MacBook password, while you are entering it, the password is not visible. <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.03.19-AM-1024x379.png\" alt=\"\" class=\"wp-image-396\" width=\"512\" height=\"190\" srcset=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.03.19-AM-1024x379.png 1024w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.03.19-AM-300x111.png 300w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.03.19-AM-768x284.png 768w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.03.19-AM.png 1140w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure><\/div>\n\n\n\n<p>b. Create a Microsoft SQL Server on your local drive<\/p>\n\n\n\n<p>Once the MS SQL Server container is <strong>successfully installed, we can proceed to the <\/strong>next step to create a SQL Server by using the following command in the <strong>Termninal<\/strong>. Before you hit the enter button, don&#8217;t forget to put your SQL Server Account password and server name in the command(the <span style=\"text-decoration: underline;\"><strong>&lt;Password&gt;<\/strong><\/span>  and <strong><span style=\"text-decoration: underline;\">&lt;Server_Name&gt;<\/span><\/strong> part in the command line).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=<span style=\"text-decoration: underline;\">&lt;Password&gt;<\/span> -p 1401:1433 --name <span style=\"text-decoration: underline;\">&lt;Server_Name&gt;<\/span> -d <meta charset=\"utf-8\">mcr.microsoft.com\/mssql\/server:2019-latest<\/code><\/pre>\n\n\n\n<p>After executing the command, you will have the SQL server created.<\/p>\n\n\n\n<p>c. Review the SQL server information<\/p>\n\n\n\n<p>Type the following command in the Terminal to retrieve the information of SQL Server we just created.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker ps -a<\/code><\/pre>\n\n\n\n<p>You should see something similar like this:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"51\" src=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.14.55-AM-1024x51.png\" alt=\"\" class=\"wp-image-397\" srcset=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.14.55-AM-1024x51.png 1024w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.14.55-AM-300x15.png 300w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.14.55-AM-768x39.png 768w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.14.55-AM-1536x77.png 1536w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.14.55-AM-2048x103.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p><strong>3. Test the SQL Server<\/strong><\/p>\n\n\n\n<p>Now we can use the MS SQL tool to test the server out. Since SSMS doesn&#8217;t have an OS version, you can use DataGrip, SQLPro Studio, or any other SQL tool to test the server. I will use SQLPro Studio and DataGrip as examples, but this should be the same as your daily connecting to the SQL server.<\/p>\n\n\n\n<p>All you need to fill out are:<\/p>\n\n\n\n<p>   Server host: 0.0.0.0<\/p>\n\n\n\n<p>   Port: 1401<\/p>\n\n\n\n<p>   Login: SA (by default)<\/p>\n\n\n\n<p>  Password: the password you set in the command line earlier<meta charset=\"utf-8\"><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>SQLPro Studio:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.17.56-AM-1024x528.png\" alt=\"\" class=\"wp-image-401\" width=\"512\" height=\"264\" srcset=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.17.56-AM-1024x528.png 1024w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.17.56-AM-300x155.png 300w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.17.56-AM-768x396.png 768w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.17.56-AM-1536x793.png 1536w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.17.56-AM-2048x1057.png 2048w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.18.37-AM-1024x536.png\" alt=\"\" class=\"wp-image-398\" width=\"512\" height=\"268\" srcset=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.18.37-AM-1024x536.png 1024w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.18.37-AM-300x157.png 300w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.18.37-AM-768x402.png 768w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.18.37-AM-1536x804.png 1536w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.18.37-AM-2048x1072.png 2048w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure><\/div>\n\n\n\n<p><strong>DataGrip<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.23.29-AM-745x1024.png\" alt=\"\" class=\"wp-image-399\" width=\"373\" height=\"512\" srcset=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.23.29-AM-745x1024.png 745w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.23.29-AM-218x300.png 218w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.23.29-AM-768x1056.png 768w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.23.29-AM.png 918w\" sizes=\"auto, (max-width: 373px) 100vw, 373px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.24.46-AM-1024x914.png\" alt=\"\" class=\"wp-image-400\" width=\"512\" height=\"457\" srcset=\"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.24.46-AM-1024x914.png 1024w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.24.46-AM-300x268.png 300w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.24.46-AM-768x686.png 768w, https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Screen-Shot-2021-08-02-at-12.24.46-AM.png 1306w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure><\/div>\n\n\n\n<p> You are all set! Enjoy your local SQL Server and have fun with data!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is more like a note for myself about how I set up a local SQL server on the MacBook. If you happened to have the same need, and the steps are not detailed enough, please leave a comment or shoot me an email. Glad to help. 1.Environment Setup a. Register a Docker Account [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":441,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[11],"tags":[14],"class_list":["post-394","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-analytics","tag-sql"],"jetpack_featured_media_url":"https:\/\/leonsworkshop.com\/wp-content\/uploads\/2021\/08\/Slide10-1.png","_links":{"self":[{"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=\/wp\/v2\/posts\/394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=394"}],"version-history":[{"count":2,"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=\/wp\/v2\/posts\/394\/revisions"}],"predecessor-version":[{"id":403,"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=\/wp\/v2\/posts\/394\/revisions\/403"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=\/wp\/v2\/media\/441"}],"wp:attachment":[{"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leonsworkshop.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}