{"id":286,"date":"2016-05-02T17:19:16","date_gmt":"2016-05-02T17:19:16","guid":{"rendered":"http:\/\/www.copahost.com\/blog\/?p=286"},"modified":"2020-05-31T14:22:18","modified_gmt":"2020-05-31T14:22:18","slug":"reset-mysql-root-password-ubuntu","status":"publish","type":"post","link":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/","title":{"rendered":"Reset MySQL root password in Ubuntu"},"content":{"rendered":"<p>To recover or reset MySQL root\u00a0password in Ubuntu, you should simply follow some steps.\u00a0This process may vary according to the operating system. Ubuntu offerts a possibility to restore the root password via dpkg, which is a native package management system.<\/p>\n<h3>Recovering the database root access: reset MySQL root password in Ubuntu<\/h3>\n<p>First, we need to stop the MySQL server:<\/p>\n<pre class=\"lang:default decode:true\">sudo service mysql stop<\/pre>\n<p>Now we will run dpkg-reconfigure , to reset the mysql password:<\/p>\n<pre class=\"\">sudo dpkg-reconfigure mysql-server-5.5<\/pre>\n<p>It will prompt for the new password, just like in the <a href=\"https:\/\/www.copahost.com\/blog\/install-mysql-ubuntu-14\/\">new installation of MySQL<\/a>. You must type the new password in this screen.<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-287 size-full\" src=\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg\" alt=\"reset mysql root password in ubuntu\" width=\"638\" height=\"376\" \/><\/p>\n<p>Now, restart the MySQL server<\/p>\n<pre class=\"\">sudo service mysql start<\/pre>\n<p>Now you will be\u00a0able to <a href=\"https:\/\/www.copahost.com\/blog\/login-registration-php-mysql-bootstrap\/\" >login using the new mysql<\/a> root password:<\/p>\n<pre class=\"lang:default decode:true\">mysql -u root -p<\/pre>\n<h3>Change a MySQL user password<\/h3>\n<p>To change an user password, you must have the current MySQL root password. You should follow these steps we will explain. In these examples we will use <strong>localhost<\/strong> , for local users connecting from the same server. If the user is authorized to connect remotely, we would have to replace it with its IP address.<\/p>\n<pre class=\"lang:default decode:true\">SET PASSWORD FOR '[user-name]'@'localhost' = PASSWORD('[new-password]');<\/pre>\n<p>There is an alternative method. You can also change the password directly in the <a href=\"https:\/\/www.copahost.com\/blog\/list-mysql-users\/\" >mysql users<\/a> table:<\/p>\n<pre class=\"sql\">use mysql;\r\nUPDATE mysql.user SET Password=PASSWORD('[new-password]') WHERE USER='[user-name]' AND Host='localhost';<\/pre>\n<p>The expected success output is:<\/p>\n<pre class=\"lang:default decode:true\">mysql&gt; UPDATE mysql.user SET Password=PASSWORD('test123test') WHERE USER='user1' AND host='localhost';\r\nQuery OK, 0 rows affected (0.00 sec)\r\nRows matched: 1 Changed: 0 Warnings: 0<\/pre>\n<p>Afterwards, you must flush privileges, so that the changes take effect:<\/p>\n<pre class=\"lang:default decode:true \">flush privileges;<\/pre>\n<p>Afterwards, you can exit mysql, and try to login with the new defined user password:<\/p>\n<pre class=\"lang:default decode:true \">mysql -u [user-name] -p<\/pre>\n<p>If you happen to use root from an external host or IP, you should \u00a0reset mysql root password manually. Just change [user-name] by root and specify the IP address authorized for the root user.<\/p>\n<p>This tutorial applies either for a <a href=\"https:\/\/www.copahost.com\/en\/dedicated-servers\">cheap dedicated server with Ubuntu<\/a>, or for a <a href=\"https:\/\/www.copahost.com\/en\/cheap-vps-hosting\">vps hosting Ubuntu server<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To recover or reset MySQL root\u00a0password in Ubuntu, you should simply follow some steps.\u00a0This process may vary according to the operating system. Ubuntu offerts a possibility to restore the root password via dpkg, which is a native package management system. Recovering the database root access: reset MySQL root password in Ubuntu First, we need to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[91],"tags":[95,96,94],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql-password","tag-reset-password","tag-root-password"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Reset MySQL root password in Ubuntu - Copahost<\/title>\n<meta name=\"description\" content=\"Guide about how to recover or reset MySQL root or admin password in Ubuntu in less than 1 minute. Applies for dedicated or vps servers running Ubuntu.\" \/>\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.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Reset MySQL root password in Ubuntu - Copahost\" \/>\n<meta property=\"og:description\" content=\"Guide about how to recover or reset MySQL root or admin password in Ubuntu in less than 1 minute. Applies for dedicated or vps servers running Ubuntu.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/\" \/>\n<meta property=\"og:site_name\" content=\"Copahost\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-02T17:19:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-31T14:22:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg\" \/>\n<meta name=\"author\" content=\"Gustavo Gallas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gustavo Gallas\" \/>\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.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/\"},\"author\":{\"name\":\"Gustavo Gallas\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/386b3f1f79299d43f4ceb33d26428246\"},\"headline\":\"Reset MySQL root password in Ubuntu\",\"datePublished\":\"2016-05-02T17:19:16+00:00\",\"dateModified\":\"2020-05-31T14:22:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/\"},\"wordCount\":278,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg\",\"keywords\":[\"mysql password\",\"reset password\",\"root password\"],\"articleSection\":[\"MySQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/\",\"url\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/\",\"name\":\"Reset MySQL root password in Ubuntu - Copahost\",\"isPartOf\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg\",\"datePublished\":\"2016-05-02T17:19:16+00:00\",\"dateModified\":\"2020-05-31T14:22:18+00:00\",\"description\":\"Guide about how to recover or reset MySQL root or admin password in Ubuntu in less than 1 minute. Applies for dedicated or vps servers running Ubuntu.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#primaryimage\",\"url\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg\",\"contentUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg\",\"width\":638,\"height\":376},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.copahost.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Reset MySQL root password in Ubuntu\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#website\",\"url\":\"https:\/\/www.copahost.com\/blog\/\",\"name\":\"Copahost\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.copahost.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#organization\",\"name\":\"Copahost\",\"url\":\"https:\/\/www.copahost.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png\",\"contentUrl\":\"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png\",\"width\":223,\"height\":40,\"caption\":\"Copahost\"},\"image\":{\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/386b3f1f79299d43f4ceb33d26428246\",\"name\":\"Gustavo Gallas\",\"description\":\"Graduated in Computing at PUC-Rio, Brazil. Specialized in IT, networking, systems administration and human and organizational development\u200b. Also have brewing skills.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/gustavo-gallas-107926196\/\"],\"url\":\"https:\/\/www.copahost.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Reset MySQL root password in Ubuntu - Copahost","description":"Guide about how to recover or reset MySQL root or admin password in Ubuntu in less than 1 minute. Applies for dedicated or vps servers running Ubuntu.","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.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/","og_locale":"en_US","og_type":"article","og_title":"Reset MySQL root password in Ubuntu - Copahost","og_description":"Guide about how to recover or reset MySQL root or admin password in Ubuntu in less than 1 minute. Applies for dedicated or vps servers running Ubuntu.","og_url":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/","og_site_name":"Copahost","article_published_time":"2016-05-02T17:19:16+00:00","article_modified_time":"2020-05-31T14:22:18+00:00","og_image":[{"url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg"}],"author":"Gustavo Gallas","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Gustavo Gallas","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#article","isPartOf":{"@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/"},"author":{"name":"Gustavo Gallas","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/386b3f1f79299d43f4ceb33d26428246"},"headline":"Reset MySQL root password in Ubuntu","datePublished":"2016-05-02T17:19:16+00:00","dateModified":"2020-05-31T14:22:18+00:00","mainEntityOfPage":{"@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/"},"wordCount":278,"commentCount":0,"publisher":{"@id":"https:\/\/www.copahost.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg","keywords":["mysql password","reset password","root password"],"articleSection":["MySQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/","url":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/","name":"Reset MySQL root password in Ubuntu - Copahost","isPartOf":{"@id":"https:\/\/www.copahost.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#primaryimage"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg","datePublished":"2016-05-02T17:19:16+00:00","dateModified":"2020-05-31T14:22:18+00:00","description":"Guide about how to recover or reset MySQL root or admin password in Ubuntu in less than 1 minute. Applies for dedicated or vps servers running Ubuntu.","breadcrumb":{"@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#primaryimage","url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg","contentUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/05\/reset-mysql-password-ubuntu.jpg","width":638,"height":376},{"@type":"BreadcrumbList","@id":"https:\/\/www.copahost.com\/blog\/reset-mysql-root-password-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.copahost.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Reset MySQL root password in Ubuntu"}]},{"@type":"WebSite","@id":"https:\/\/www.copahost.com\/blog\/#website","url":"https:\/\/www.copahost.com\/blog\/","name":"Copahost","description":"","publisher":{"@id":"https:\/\/www.copahost.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.copahost.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.copahost.com\/blog\/#organization","name":"Copahost","url":"https:\/\/www.copahost.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png","contentUrl":"https:\/\/www.copahost.com\/blog\/wp-content\/uploads\/2016\/03\/copahostlogo.png","width":223,"height":40,"caption":"Copahost"},"image":{"@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.copahost.com\/blog\/#\/schema\/person\/386b3f1f79299d43f4ceb33d26428246","name":"Gustavo Gallas","description":"Graduated in Computing at PUC-Rio, Brazil. Specialized in IT, networking, systems administration and human and organizational development\u200b. Also have brewing skills.","sameAs":["https:\/\/www.linkedin.com\/in\/gustavo-gallas-107926196\/"],"url":"https:\/\/www.copahost.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/comments?post=286"}],"version-history":[{"count":4,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":426,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/posts\/286\/revisions\/426"}],"wp:attachment":[{"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/media?parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/categories?post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.copahost.com\/blog\/wp-json\/wp\/v2\/tags?post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}