{"id":23320,"date":"2023-03-15T16:47:30","date_gmt":"2023-03-15T15:47:30","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=23320"},"modified":"2023-03-15T16:47:30","modified_gmt":"2023-03-15T15:47:30","slug":"lost-access-to-sql-server-now-what","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/","title":{"rendered":"Lost access to SQL Server. Now what ?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In this blog we will explain what to do to regain the access to your SQL Server instance.  Here is our scenario : <br>&#8211; You have by accident removed all logins in SQL Server instance <br>&#8211; Your <strong>sa<\/strong> account by security and best practice is disabled <br>&#8211; So no possibility to login with a <strong>sqlcmd<\/strong> or your <strong>SSMS<\/strong> (SQL Server Management Studio) tools<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First thing first, take a deep breath and be calm.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/media.giphy.com\/media\/3o6vXJZlfNfAYysryo\/giphy.gif\" alt=\"\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then here are the steps to regain your access to the SQL Server instance<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1- Connect to your server where the SQL Server instance is installed (do a RDP connection)<br><br>2- Make sure your are administrator on this server. This is really important <br><br>3- Stop the SQL Server instance by using the SQL Server Configuration Manager.<br><br>4- Run powershell as administrator <br><br>5- Navigate to the folder where the SQL Server executable is located. The default location is <code>\"C:\\Program Files\\Microsoft SQL Server\\MSSQL15.MSSQLSERVER\\MSSQL\\Binn\"<\/code> for SQL Server 2019<br><br>6- Type the following command and press Enter: (This command starts the SQL Server instance in single-user mode)<br><code>sqlservr.exe -m<\/code><br><br>7- Run another Powershell as administrator <br><br>8- Type the following command and press Enter: (This command will let you to connect to the instance)<br><code>sqlcmd -S localhost -E<\/code> <br><br>9- Now all you need to do is to create a login with the sysadmin role <br><code>CREATE LOGIN [LIFESAVER] WITH PASSWORD = 'Pa$$word123456'<br>GO<br>ALTER SERVER ROLE [sysadmin] ADD MEMBER [LIFESAVER]<br>GO<\/code><br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here we go, Now you can restart your instance and login with your login freshly created and then recreate your removed logins again. <br><br>enjoy \ud83d\ude00<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> <br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog we will explain what to do to regain the access to your SQL Server instance. Here is our scenario : &#8211; You have by accident removed all logins in SQL Server instance &#8211; Your sa account by security and best practice is disabled &#8211; So no possibility to login with a sqlcmd&hellip;&nbsp;<\/p>\n","protected":false},"author":26,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","neve_meta_reading_time":"","_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[4133,99],"tags":[790,2871,2082],"class_list":["post-23320","post","type-post","status-publish","format-standard","category-database","category-sql-server","tag-disaster-recovery","tag-sqlcmd","tag-ssms"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.9 (Yoast SEO v28.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Lost access to SQL Server. Now what ? - dbi services Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Lost access to SQL Server. Now what ?\" \/>\n<meta property=\"og:description\" content=\"In this blog we will explain what to do to regain the access to your SQL Server instance. Here is our scenario : &#8211; You have by accident removed all logins in SQL Server instance &#8211; Your sa account by security and best practice is disabled &#8211; So no possibility to login with a sqlcmd&hellip;&nbsp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi services Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/dbiservices\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-15T15:47:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/media.giphy.com\/media\/3o6vXJZlfNfAYysryo\/giphy.gif\" \/>\n<meta name=\"author\" content=\"Microsoft Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:site\" content=\"@dbiservices\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Microsoft Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/\"},\"author\":{\"name\":\"Microsoft Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/857c83b2f1d7d3e7c113ed40edf63294\"},\"headline\":\"Lost access to SQL Server. Now what ?\",\"datePublished\":\"2023-03-15T15:47:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/\"},\"wordCount\":242,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/media.giphy.com\\\/media\\\/3o6vXJZlfNfAYysryo\\\/giphy.gif\",\"keywords\":[\"disaster recovery\",\"sqlcmd\",\"SSMS\"],\"articleSection\":[\"Database\",\"SQL Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/\",\"name\":\"Lost access to SQL Server. Now what ? - dbi services Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/media.giphy.com\\\/media\\\/3o6vXJZlfNfAYysryo\\\/giphy.gif\",\"datePublished\":\"2023-03-15T15:47:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/#primaryimage\",\"url\":\"https:\\\/\\\/media.giphy.com\\\/media\\\/3o6vXJZlfNfAYysryo\\\/giphy.gif\",\"contentUrl\":\"https:\\\/\\\/media.giphy.com\\\/media\\\/3o6vXJZlfNfAYysryo\\\/giphy.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/lost-access-to-sql-server-now-what\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lost access to SQL Server. Now what ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi services Blog\",\"description\":\"#BeSharing\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/#organization\",\"name\":\"dbi services\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/dbi-services-logo.png\",\"width\":512,\"height\":512,\"caption\":\"dbi services\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/dbiservices\\\/\",\"https:\\\/\\\/x.com\\\/dbiservices\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/dbi-services\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/dbiservices\"],\"description\":\"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.\",\"email\":\"info@dbi-services.com\",\"telephone\":\"+41 32 422 96 00\",\"legalName\":\"dbi services SA\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/857c83b2f1d7d3e7c113ed40edf63294\",\"name\":\"Microsoft Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/microsoft-square.png\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/microsoft-square.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/microsoft-square.png\",\"caption\":\"Microsoft Team\"},\"description\":\"Posts published under the Microsoft Team account are collective contributions by the dbi services Microsoft consultants. The practice covers SQL Server across its lifecycle, from installation, migration, and security to high availability with Always On and performance tuning, together with Azure data services and the Microsoft Business Intelligence stack, including Power BI. The team holds Microsoft certifications up to Expert level and operates customer platforms under service level agreements.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/microsoft-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Lost access to SQL Server. Now what ? - dbi services Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/","og_locale":"en_US","og_type":"article","og_title":"Lost access to SQL Server. Now what ?","og_description":"In this blog we will explain what to do to regain the access to your SQL Server instance. Here is our scenario : &#8211; You have by accident removed all logins in SQL Server instance &#8211; Your sa account by security and best practice is disabled &#8211; So no possibility to login with a sqlcmd&hellip;&nbsp;","og_url":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/","og_site_name":"dbi services Blog","article_publisher":"https:\/\/www.facebook.com\/dbiservices\/","article_published_time":"2023-03-15T15:47:30+00:00","og_image":[{"url":"https:\/\/media.giphy.com\/media\/3o6vXJZlfNfAYysryo\/giphy.gif","type":"","width":"","height":""}],"author":"Microsoft Team","twitter_card":"summary_large_image","twitter_creator":"@dbiservices","twitter_site":"@dbiservices","twitter_misc":{"Written by":"Microsoft Team","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/"},"author":{"name":"Microsoft Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/857c83b2f1d7d3e7c113ed40edf63294"},"headline":"Lost access to SQL Server. Now what ?","datePublished":"2023-03-15T15:47:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/"},"wordCount":242,"commentCount":0,"publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/#primaryimage"},"thumbnailUrl":"https:\/\/media.giphy.com\/media\/3o6vXJZlfNfAYysryo\/giphy.gif","keywords":["disaster recovery","sqlcmd","SSMS"],"articleSection":["Database","SQL Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/","url":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/","name":"Lost access to SQL Server. Now what ? - dbi services Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/#primaryimage"},"thumbnailUrl":"https:\/\/media.giphy.com\/media\/3o6vXJZlfNfAYysryo\/giphy.gif","datePublished":"2023-03-15T15:47:30+00:00","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/#primaryimage","url":"https:\/\/media.giphy.com\/media\/3o6vXJZlfNfAYysryo\/giphy.gif","contentUrl":"https:\/\/media.giphy.com\/media\/3o6vXJZlfNfAYysryo\/giphy.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/lost-access-to-sql-server-now-what\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Lost access to SQL Server. Now what ?"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi services Blog","description":"#BeSharing","publisher":{"@id":"https:\/\/www.dbi-services.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.dbi-services.com\/#organization","name":"dbi services","url":"https:\/\/www.dbi-services.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2026\/09\/dbi-services-logo.png","width":512,"height":512,"caption":"dbi services"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/dbiservices\/","https:\/\/x.com\/dbiservices","https:\/\/www.linkedin.com\/company\/dbi-services\/","https:\/\/www.youtube.com\/user\/dbiservices"],"description":"Swiss IT consulting and services company specialized in efficient data infrastructures and platforms: databases, application servers, cloud, DevOps, digitalization, analytics, data quality and monitoring. Headquartered in Del\u00e9mont with offices in Nyon, Basel, Bern and Zurich.","email":"info@dbi-services.com","telephone":"+41 32 422 96 00","legalName":"dbi services SA"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/857c83b2f1d7d3e7c113ed40edf63294","name":"Microsoft Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/12\/microsoft-square.png","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/12\/microsoft-square.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/2022\/12\/microsoft-square.png","caption":"Microsoft Team"},"description":"Posts published under the Microsoft Team account are collective contributions by the dbi services Microsoft consultants. The practice covers SQL Server across its lifecycle, from installation, migration, and security to high availability with Always On and performance tuning, together with Azure data services and the Microsoft Business Intelligence stack, including Power BI. The team holds Microsoft certifications up to Expert level and operates customer platforms under service level agreements.","url":"https:\/\/www.dbi-services.com\/blog\/author\/microsoft-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/23320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=23320"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/23320\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=23320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=23320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=23320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}