{"id":7656,"date":"2018-06-26T23:38:44","date_gmt":"2018-06-26T15:38:44","guid":{"rendered":"http:\/\/rmohan.com\/?p=7656"},"modified":"2018-06-26T23:38:44","modified_gmt":"2018-06-26T15:38:44","slug":"how-to-reset-your-root-mysql-password","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7656","title":{"rendered":"How to reset your root MySQL password"},"content":{"rendered":"<pre>Stop the MySQL process\r\n# service mysqld stop\r\n\r\nOnce MySQL has stopped, restart it with the --skip-grant-tables option\r\n# mysqld_safe --skip-grant-tables &amp;\r\nor edit your \/etc\/my.cnf file to add the line\r\nskip-grant-tables\r\n\r\nConnect to MySQL using the root user.\r\nmysql -u root\r\n\r\nOnce logged in, you should see the following prompt:\r\nmysql&gt;\r\nEnter the following commands:\r\nmysql&gt; use mysql;\r\nmysql&gt; UPDATE user SET password=PASSWORD(\"YOUR NEW PASSWORD HERE\") WHERE User='root';\r\nmysql&gt; flush privileges;\r\nmysql&gt; quit\r\n\r\nNow stop MySQL again:\r\n# service mysqld stop\r\n\r\nIf you edited your \/etc\/my.cnf file, delelete the skip-grant-tables line.\r\n\r\nNow restart MySQL and test your new login.\r\n# service mysqld restart\r\n# mysql -u root -p\r\n\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>MariaDB [(none)]&gt; CREATE USER xxxx;<br \/>\nQuery OK, 0 rows affected (0.00 sec)<\/p>\n<p>MariaDB [(none)]&gt; CREATE USER xxxx@hostname ;<br \/>\nQuery OK, 0 rows affected (0.00 sec)<\/p>\n<p>MariaDB [(none)]&gt; GRANT ALL PRIVILEGES ON dbane.* To &#8216;xxxxx@hostname&#8217; IDENTIFIED BY &#8216;P@ssw0rd5768#&#8217;;<br \/>\nQuery OK, 0 rows affected (0.00 sec)<\/p>\n<p>MariaDB [(none)]&gt; FLUSH PRIVILEGES;<\/p>\n<p>GRANT ALL PRIVILEGES ON db.* To &#8216;usernam&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;P@ssw0rd5768#&#8217;;<br \/>\nGRANT USAGE ON *.* TO &#8216;usernam&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;P@ssw0rd5768#&#8217;;<\/p>\n<p>&nbsp;<\/p>\n<p>Reset root password<\/p>\n<p>UPDATE user SET authentication_string=password(&#8216;password&#8217;) WHERE user=&#8217;root&#8217;;<\/p>\n<p>update mysql.user set password_expired = &#8216;N&#8217;, authentication_string=PASSWORD(&#8216;password&#8217;) where user = &#8216;root&#8217;;<\/p>\n<p>GRANT USAGE ON *.* TO &#8216;root&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;password&#8217;;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Stop the MySQL process # service mysqld stop Once MySQL has stopped, restart it with the &#8211;skip-grant-tables option # mysqld_safe &#8211;skip-grant-tables &amp; or edit your \/etc\/my.cnf file to add the line skip-grant-tables Connect to MySQL using the root user. mysql -u root Once logged in, you should see the following prompt: mysql&gt; Enter the following [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7656"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7656"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7656\/revisions"}],"predecessor-version":[{"id":7657,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7656\/revisions\/7657"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}