{"id":201,"date":"2016-09-13T13:46:41","date_gmt":"2016-09-13T13:46:41","guid":{"rendered":"http:\/\/linux.suriyasuneel.com\/?p=201"},"modified":"2016-09-13T13:46:41","modified_gmt":"2016-09-13T13:46:41","slug":"reset-mysql-root-password-if-forgotten","status":"publish","type":"post","link":"http:\/\/linux.suriyasuneel.com\/?p=201","title":{"rendered":"Reset mysql root password if forgotten"},"content":{"rendered":"<h2 id=\"How_can_I_reset_my_MySQL_password.3F\">How can I reset my MySQL password?<\/h2>\n<p class=\"line867\"><img decoding=\"async\" class=\"attachment\" title=\"IconsPage\/warning.png\" src=\"https:\/\/help.ubuntu.com\/community\/IconsPage?action=AttachFile&amp;do=get&amp;target=warning.png\" alt=\"IconsPage\/warning.png\" \/> Following this procedure, you will disable access control on the MySQL server. All connexions will have a root access. It is a good thing to unplug your server from the network or at least disable remote access.<span id=\"line-31\" class=\"anchor\"><\/span><span id=\"line-32\" class=\"anchor\"><\/span><\/p>\n<p class=\"line874\">To reset your mysqld password just follow these instructions :<span id=\"line-33\" class=\"anchor\"><\/span><span id=\"line-34\" class=\"anchor\"><\/span><\/p>\n<ul>\n<li>Stop the mysql demon process using this command :<span id=\"line-35\" class=\"anchor\"><\/span>\n<ul>\n<li><span id=\"line-36\" class=\"anchor\"><\/span><span id=\"line-37\" class=\"anchor\"><\/span>\n<pre><span id=\"line-1-2\" class=\"anchor\"><\/span>   sudo \/etc\/init.d\/mysql stop<\/pre>\n<p><span id=\"line-38\" class=\"anchor\"><\/span><\/li>\n<\/ul>\n<\/li>\n<li>Start the mysqld demon process using the &#8211;skip-grant-tables option with this command <span id=\"line-39\" class=\"anchor\"><\/span>\n<ul>\n<li><span id=\"line-40\" class=\"anchor\"><\/span><span id=\"line-41\" class=\"anchor\"><\/span>\n<pre><span id=\"line-1-3\" class=\"anchor\"><\/span>   sudo \/usr\/sbin\/mysqld --skip-grant-tables --skip-networking &amp;<\/pre>\n<p><span id=\"line-42\" class=\"anchor\"><\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p class=\"line867\"><strong>Because you are not checking user privs at this point, it&#8217;s safest to disable networking.<\/strong> <span id=\"line-43\" class=\"anchor\"><\/span><strong>In Dapper, \/usr\/bin\/mysqld&#8230; did not work. However, <tt>mysqld\u00a0--skip-grant-tables<\/tt> did.<\/strong><span id=\"line-44\" class=\"anchor\"><\/span><\/p>\n<ul>\n<li>start the mysql client process using this command <span id=\"line-45\" class=\"anchor\"><\/span>\n<ul>\n<li><span id=\"line-46\" class=\"anchor\"><\/span><span id=\"line-47\" class=\"anchor\"><\/span>\n<pre><span id=\"line-1-4\" class=\"anchor\"><\/span>   mysql -u root<\/pre>\n<p><span id=\"line-48\" class=\"anchor\"><\/span><\/li>\n<\/ul>\n<\/li>\n<li>from the mysql prompt execute this command to be able to change any password<span id=\"line-49\" class=\"anchor\"><\/span>\n<ul>\n<li><span id=\"line-50\" class=\"anchor\"><\/span><span id=\"line-51\" class=\"anchor\"><\/span>\n<pre><span id=\"line-1-5\" class=\"anchor\"><\/span>   FLUSH PRIVILEGES;<\/pre>\n<p><span id=\"line-52\" class=\"anchor\"><\/span><\/li>\n<\/ul>\n<\/li>\n<li>Then reset\/update your password <span id=\"line-53\" class=\"anchor\"><\/span>\n<ul>\n<li><span id=\"line-54\" class=\"anchor\"><\/span><span id=\"line-55\" class=\"anchor\"><\/span>\n<pre><span id=\"line-1-6\" class=\"anchor\"><\/span>   SET PASSWORD FOR root@'localhost' = PASSWORD('password');<\/pre>\n<p><span id=\"line-56\" class=\"anchor\"><\/span><\/li>\n<\/ul>\n<\/li>\n<li>If you have a mysql root account that can connect from everywhere, you should also do:<span id=\"line-57\" class=\"anchor\"><\/span>\n<ul>\n<li><span id=\"line-58\" class=\"anchor\"><\/span><span id=\"line-59\" class=\"anchor\"><\/span>\n<pre><span id=\"line-1-7\" class=\"anchor\"><\/span>   UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';<\/pre>\n<p><span id=\"line-60\" class=\"anchor\"><\/span><span id=\"line-61\" class=\"anchor\"><\/span><\/li>\n<\/ul>\n<\/li>\n<li class=\"gap\">Alternate Method:<span id=\"line-62\" class=\"anchor\"><\/span>\n<ul>\n<li><span id=\"line-63\" class=\"anchor\"><\/span><span id=\"line-64\" class=\"anchor\"><\/span><span id=\"line-65\" class=\"anchor\"><\/span><span id=\"line-66\" class=\"anchor\"><\/span>\n<pre><span id=\"line-1-8\" class=\"anchor\"><\/span>   USE mysql\r\n<span id=\"line-2-2\" class=\"anchor\"><\/span>   UPDATE user SET Password = PASSWORD('newpwd')\r\n<span id=\"line-3\" class=\"anchor\"><\/span>   WHERE Host = 'localhost' AND User = 'root';<\/pre>\n<p><span id=\"line-67\" class=\"anchor\"><\/span><\/li>\n<\/ul>\n<\/li>\n<li>And if you have a root account that can access from everywhere:<span id=\"line-68\" class=\"anchor\"><\/span>\n<ul>\n<li><span id=\"line-69\" class=\"anchor\"><\/span><span id=\"line-70\" class=\"anchor\"><\/span><span id=\"line-71\" class=\"anchor\"><\/span><span id=\"line-72\" class=\"anchor\"><\/span>\n<pre><span id=\"line-1-9\" class=\"anchor\"><\/span>   USE mysql\r\n<span id=\"line-2-3\" class=\"anchor\"><\/span>   UPDATE user SET Password = PASSWORD('newpwd')\r\n<span id=\"line-3-1\" class=\"anchor\"><\/span>   WHERE Host = '%' AND User = 'root';<\/pre>\n<p><span id=\"line-73\" class=\"anchor\"><\/span><span id=\"line-74\" class=\"anchor\"><\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p class=\"line874\">For either method, once have received a message indicating a successful query (one or more rows affected), flush privileges:<span id=\"line-75\" class=\"anchor\"><\/span><span id=\"line-76\" class=\"anchor\"><\/span><span id=\"line-77\" class=\"anchor\"><\/span><\/p>\n<pre><span id=\"line-1-10\" class=\"anchor\"><\/span>FLUSH PRIVILEGES;<\/pre>\n<p class=\"line862\">Then stop the <tt>mysqld<\/tt> process and relaunch it with the classical way:<span id=\"line-80\" class=\"anchor\"><\/span><span id=\"line-81\" class=\"anchor\"><\/span><span id=\"line-82\" class=\"anchor\"><\/span><span id=\"line-83\" class=\"anchor\"><\/span><\/p>\n<pre><span id=\"line-1-11\" class=\"anchor\"><\/span>sudo \/etc\/init.d\/mysql stop\r\n<span id=\"line-2-4\" class=\"anchor\"><\/span>sudo \/etc\/init.d\/mysql start<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How can I reset my MySQL password? Following this procedure, you will disable access control on the MySQL server. All connexions will have a root access. It is a good thing to unplug your server from the network or at least disable remote access. To reset your mysqld password just follow these instructions : Stop [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/201"}],"collection":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=201"}],"version-history":[{"count":1,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions"}],"predecessor-version":[{"id":202,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/201\/revisions\/202"}],"wp:attachment":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}