{"id":2373,"date":"2014-04-27T11:00:55","date_gmt":"2014-04-27T15:00:55","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=2373"},"modified":"2014-11-13T12:28:36","modified_gmt":"2014-11-13T17:28:36","slug":"create-database-master-key","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/","title":{"rendered":"How to Create a Database Master Key"},"content":{"rendered":"<div>\n<h3>Introduction<\/h3>\n<p>\nThe database master key is the root of the encryption hierarchy within a single database. It is a symmetric key that is stored in its database and that can be used to protect certificates and asymmetric keys. The database master key itself is protected with one or more passwords and additionally with the <a href=\"http:\/\/sqlity.net\/en\/2368\/service-master-key\/\">service master key<\/a>.\n<\/p>\n<h3>Creating the Database Master Key<\/h3>\n<p>\nThe <span class=\"tt\">CREATE MASTER KEY<\/span> statement can be used to create the database master key for the current database. The statement requires a password to be specified. That password has to comply with the local password policies.\n<\/p>\n<div>\n[sql]\nCREATE MASTER KEY ENCRYPTION BY PASSWORD = '************';<br \/>\n[\/sql]\n<\/div>\n<p>\nAfter the key is created with this statement, it is protected by the specified password. However, it is also automatically protected by the service master key. You cannot change this behavior, but you can alter the key after it was created to drop the encryption by the service master key.\n<\/p>\n<h3>Does the Database Master Key exist?<\/h3>\n<p>\nTo check if the database master key exists, you can use the <span class=\"tt\">sys.symmetric_keys<\/span> catalog view like this:\n<\/p>\n<div>\n[sql]\nSELECT *<br \/>\n  FROM sys.symmetric_keys AS SK<br \/>\n WHERE SK.name = '##MS_DatabaseMasterKey##';<br \/>\n[\/sql]\n<\/div>\n<p>\nOn my machine, this statement produces the following output:\n<\/p>\n<p>\n<a href=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg\" alt=\"The Database Master Key\" title=\"The Database Master Key\" width=\"816\" height=\"483\" class=\"aligncenter size-full wp-image-2374\" srcset=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg 816w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key-300x177.jpg 300w, https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key-150x88.jpg 150w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/a>\n<\/p>\n<h3>Summary<\/h3>\n<p>\nThe database master key is at the root of the encryption hierarchy within a single SQL Server database and can provide protection for asymmetric keys and certificates. The database master key itself is protected by the service master key.\n<\/p>\n<h3>Encryption Hierarchy Series<\/h3>\n<p>\nThis article is part of the <a href=\"http:\/\/sqlity.net\/en\/topic\/series\/encryption-hierarchy\/\">Encryption Hierarchy<\/a> series. Check out <a href=\"http:\/\/sqlity.net\/en\/2357\/encryption-hierarchy\/\">The SQL Server Encryption Hierarchy<\/a> for an overview of the hierarchy and a list of all posts that are part of the series.\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Discover how to create and protect the Database Master Key that builds the base of a database encryption hierarchy and in turn can protect certificates and asymmetric keys in its database.<\/p>\n<p> <a href=\"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":2374,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[32,167,5,34,27],"tags":[273,172,38,171,15],"class_list":["post-2373","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cryptography","category-encryption-hierarchy","category-general","category-security","category-series","tag-cryptography","tag-database-master-key","tag-security-2","tag-service-master-key","tag-sql-server"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Create a Database Master Key - sqlity.net<\/title>\n<meta name=\"description\" content=\"Discover how to create the Database Master Key that builds the base of a database encryption hierarchy and can protect certificates and asymmetric keys.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Create a Database Master Key - sqlity.net\" \/>\n<meta property=\"og:description\" content=\"Discover how to create the Database Master Key that builds the base of a database encryption hierarchy and can protect certificates and asymmetric keys.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/\" \/>\n<meta property=\"og:site_name\" content=\"sqlity.net\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sqlity.net\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-27T15:00:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-13T17:28:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"816\" \/>\n\t<meta property=\"og:image:height\" content=\"483\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sebastian Meine\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sqlity\" \/>\n<meta name=\"twitter:site\" content=\"@sqlity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sebastian Meine\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"How to Create a Database Master Key\",\"datePublished\":\"2014-04-27T15:00:55+00:00\",\"dateModified\":\"2014-11-13T17:28:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/\"},\"wordCount\":296,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/04\\\/database_master_key.jpg\",\"keywords\":[\"Cryptography\",\"Database Master Key\",\"security\",\"Service Master Key\",\"SQL Server\"],\"articleSection\":[\"Cryptography\",\"Encryption Hierarchy\",\"General\",\"Security\",\"Series\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/\",\"name\":\"How to Create a Database Master Key - sqlity.net\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/04\\\/database_master_key.jpg\",\"datePublished\":\"2014-04-27T15:00:55+00:00\",\"dateModified\":\"2014-11-13T17:28:36+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"Discover how to create the Database Master Key that builds the base of a database encryption hierarchy and can protect certificates and asymmetric keys.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/#primaryimage\",\"url\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/04\\\/database_master_key.jpg\",\"contentUrl\":\"https:\\\/\\\/sqlity.net\\\/wp-content\\\/uploads\\\/2014\\\/04\\\/database_master_key.jpg\",\"width\":816,\"height\":483,\"caption\":\"The Database Master Key\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/2373\\\/create-database-master-key\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Create a Database Master Key\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\",\"name\":\"sqlity.net\",\"description\":\"Quality for SQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sqlity.net\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\",\"name\":\"Sebastian Meine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"caption\":\"Sebastian Meine\"},\"sameAs\":[\"http:\\\/\\\/sqlity.net\",\"https:\\\/\\\/x.com\\\/sqlity\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Create a Database Master Key - sqlity.net","description":"Discover how to create the Database Master Key that builds the base of a database encryption hierarchy and can protect certificates and asymmetric keys.","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:\/\/sqlity.net\/en\/2373\/create-database-master-key\/","og_locale":"en_US","og_type":"article","og_title":"How to Create a Database Master Key - sqlity.net","og_description":"Discover how to create the Database Master Key that builds the base of a database encryption hierarchy and can protect certificates and asymmetric keys.","og_url":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2014-04-27T15:00:55+00:00","article_modified_time":"2014-11-13T17:28:36+00:00","og_image":[{"width":816,"height":483,"url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg","type":"image\/jpeg"}],"author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"How to Create a Database Master Key","datePublished":"2014-04-27T15:00:55+00:00","dateModified":"2014-11-13T17:28:36+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/"},"wordCount":296,"commentCount":1,"image":{"@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg","keywords":["Cryptography","Database Master Key","security","Service Master Key","SQL Server"],"articleSection":["Cryptography","Encryption Hierarchy","General","Security","Series"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/","url":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/","name":"How to Create a Database Master Key - sqlity.net","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/#primaryimage"},"thumbnailUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg","datePublished":"2014-04-27T15:00:55+00:00","dateModified":"2014-11-13T17:28:36+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"Discover how to create the Database Master Key that builds the base of a database encryption hierarchy and can protect certificates and asymmetric keys.","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/#primaryimage","url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg","contentUrl":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg","width":816,"height":483,"caption":"The Database Master Key"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/2373\/create-database-master-key\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"How to Create a Database Master Key"}]},{"@type":"WebSite","@id":"https:\/\/sqlity.net\/en\/#website","url":"https:\/\/sqlity.net\/en\/","name":"sqlity.net","description":"Quality for SQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sqlity.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c","name":"Sebastian Meine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","caption":"Sebastian Meine"},"sameAs":["http:\/\/sqlity.net","https:\/\/x.com\/sqlity"]}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-Ch","jetpack-related-posts":[],"jetpack_featured_media_url":"https:\/\/sqlity.net\/wp-content\/uploads\/2014\/04\/database_master_key.jpg","_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/comments?post=2373"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/2373\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media\/2374"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=2373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=2373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=2373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}