{"id":1018,"date":"2021-02-28T11:41:27","date_gmt":"2021-02-28T09:41:27","guid":{"rendered":"http:\/\/www.netexpertise.eu\/en\/?p=1018"},"modified":"2021-03-08T08:55:16","modified_gmt":"2021-03-08T06:55:16","slug":"change-procedure-function-security-type-and-definer","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html","title":{"rendered":"Change Procedure\/Function Security Type and DEFINER"},"content":{"rendered":"\n<p><a href=\"\/en\/category\/database\/mysql\">Mysql<\/a> procedures and functions security type is set as DEFINER which is the default value, as described in the &#8220;Create Procedure and create function chapter&#8221; on <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/create-procedure.html\">mysql.com<\/a>.<br>Why one needs to be cautious? Anyone with EXECUTE privilege can run the procedure or function with the DEFINER permissions. This might not be what you want.<\/p>\n\n\n\n<p>An error may be raised when someone tries to run the procedure\/function which definer has been deleted<br><em>ERROR 1449 (HY000): The user specified as a definer (&#8216;definer&#8217;@&#8217;localhost&#8217;) does not exist<\/em><br>As a result, you may have to change definer and\/or security type on a lot of procedures and functions at once.<br>It is interesting to note that a missing user doesn&#8217;t bother Mysql while dumping and restoring unlike views that raise an error.<\/p>\n\n\n\n<p><br>First off, you can have a quick glance at your procedures and functions with the 2 basic:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">SHOW FUNCTION STATUS;\nSHOW PROCEDURE STATUS;<\/code><\/pre>\n\n\n\n<p>You may add a LIKE &#8216;my_proc&#8217;, or WHERE Db LIKE &#8216;my_database&#8217; for filtering out results<\/p>\n\n\n\n<p><br>Now, it is always possible to change definers and security type with Mysql <a href=\"https:\/\/www.mysql.com\/fr\/products\/workbench\/\">Workbench<\/a>, or recreating them in SQL but your best bet is to change them all at once in command line (narrow update using the WHERE clause to apply to some):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">UPDATE mysql.proc SET security_type='INVOKER'\nWHERE security_type='DEFINER';<\/code><\/pre>\n\n\n\n<p><br>You can also update DEFINER as well with the following query:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"sql\" class=\"language-sql\">UPDATE mysql.proc SET definer='root@localhost'\nWHERE NOT definer='root@localhost';<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Mysql procedures and functions security type is set as DEFINER which is the default value, as described in the &#8220;Create Procedure and create function chapter&#8221; on mysql.com.Why one needs to be cautious? Anyone with EXECUTE privilege can run the procedure or function with the DEFINER permissions. This might not be what you want. An error [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"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},"categories":[4],"tags":[385,389],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - Change Procedure\/Function Security Type and DEFINER<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - Change Procedure\/Function Security Type and DEFINER\" \/>\n<meta property=\"og:description\" content=\"Mysql procedures and functions security type is set as DEFINER which is the default value, as described in the &#8220;Create Procedure and create function chapter&#8221; on mysql.com.Why one needs to be cautious? Anyone with EXECUTE privilege can run the procedure or function with the DEFINER permissions. This might not be what you want. An error [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-28T09:41:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-08T06:55:16+00:00\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html\",\"name\":\"Netexpertise - Change Procedure\/Function Security Type and DEFINER\",\"isPartOf\":{\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2021-02-28T09:41:27+00:00\",\"dateModified\":\"2021-03-08T06:55:16+00:00\",\"author\":{\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"breadcrumb\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Change Procedure\/Function Security Type and DEFINER\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"https:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - Change Procedure\/Function Security Type and DEFINER","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":"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - Change Procedure\/Function Security Type and DEFINER","og_description":"Mysql procedures and functions security type is set as DEFINER which is the default value, as described in the &#8220;Create Procedure and create function chapter&#8221; on mysql.com.Why one needs to be cautious? Anyone with EXECUTE privilege can run the procedure or function with the DEFINER permissions. This might not be what you want. An error [&hellip;]","og_url":"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html","og_site_name":"Netexpertise","article_published_time":"2021-02-28T09:41:27+00:00","article_modified_time":"2021-03-08T06:55:16+00:00","author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html","url":"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html","name":"Netexpertise - Change Procedure\/Function Security Type and DEFINER","isPartOf":{"@id":"https:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2021-02-28T09:41:27+00:00","dateModified":"2021-03-08T06:55:16+00:00","author":{"@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"breadcrumb":{"@id":"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.netexpertise.eu\/en\/database\/mysql\/change-procedure-function-security-type-and-definer.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"Change Procedure\/Function Security Type and DEFINER"}]},{"@type":"WebSite","@id":"https:\/\/www.netexpertise.eu\/en\/#website","url":"https:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/1018"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=1018"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/1018\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=1018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=1018"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=1018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}